/* ============================================
   CITACLICK — BASE STYLES
   Mobile First — 375px base
   ============================================ */

/* --- BODY & TYPOGRAPHY --- */

html, body {
  overflow-x: hidden;
  width: 100%;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: var(--weight-regular);
  line-height: var(--leading-normal);
  color: var(--color-text);
  background-color: var(--color-surface);
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
  color: var(--color-text);
}

h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }
h5 { font-size: var(--text-md); }
h6 { font-size: var(--text-base); }

.text-display {
  font-family: var(--font-display);
  font-weight: var(--weight-bold);
}

.text-body {
  font-family: var(--font-body);
}

.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.text-lg { font-size: var(--text-lg); }
.text-muted { color: var(--color-text-muted); }
.text-secondary { color: var(--color-text-secondary); }


/* --- APP LAYOUT --- */

.app-layout {
  display: flex;
  min-height: 100dvh;
}

.app-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100dvh;
  background-color: var(--color-surface-raised);
  border-right: 1px solid var(--color-border-light);
  z-index: var(--z-sidebar);
  display: flex;
  flex-direction: column;
  transition: transform var(--transition-base);
  overflow-y: auto;
  overflow-x: hidden;
}

.app-main {
  flex: 1;
  margin-left: 0;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  transition: margin-left var(--transition-base);
}

.app-header {
  position: sticky;
  top: 0;
  height: var(--header-height);
  background-color: var(--color-surface-raised);
  border-bottom: 1px solid var(--color-border-light);
  z-index: var(--z-sticky);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-4);
  gap: var(--space-3);
}

.app-content {
  flex: 1;
  padding: var(--space-4);
  max-width: var(--content-max-width);
  width: 100%;
  margin: 0 auto;
}

.app-footer {
  height: var(--footer-height);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 var(--space-4);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.app-footer a {
  color: var(--color-text-muted);
  transition: color var(--transition-fast);
}

.app-footer a:hover {
  color: var(--color-highlight);
}

/* Mobile: sidebar hidden by default */
.app-sidebar {
  transform: translateX(-100%);
}

.app-sidebar.open {
  transform: translateX(0);
}


/* --- CARDS --- */

.card {
  background-color: var(--color-surface-raised);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-fast);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.card-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
}

.card-body {
  font-size: var(--text-base);
  line-height: var(--leading-relaxed);
}

.card-footer {
  margin-top: var(--space-4);
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-border-light);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
}


/* --- BUTTONS --- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  line-height: 1;
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background-color: var(--color-highlight);
  color: var(--color-text-inverse);
  border-color: var(--color-highlight);
}

.btn-primary:hover {
  filter: brightness(1.1);
  box-shadow: var(--shadow-md);
}

.btn-primary:active {
  filter: brightness(0.95);
}

.btn-secondary {
  background-color: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-border);
}

.btn-secondary:hover {
  background-color: var(--color-surface-sunken);
  border-color: var(--color-text-muted);
}

.btn-secondary:active {
  background-color: var(--color-border-light);
}

.btn-ghost {
  background-color: transparent;
  color: var(--color-text-secondary);
  border-color: transparent;
}

.btn-ghost:hover {
  background-color: var(--color-surface-sunken);
  color: var(--color-text);
}

.btn-ghost:active {
  background-color: var(--color-border-light);
}

.btn-danger {
  background-color: var(--color-error);
  color: var(--color-text-inverse);
  border-color: var(--color-error);
}

.btn-danger:hover {
  filter: brightness(1.1);
  box-shadow: var(--shadow-md);
}

.btn-sm {
  font-size: var(--text-sm);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
}

.btn-lg {
  font-size: var(--text-lg);
  padding: var(--space-4) var(--space-8);
  border-radius: var(--radius-lg);
}

.btn-full {
  width: 100%;
}

.btn-icon {
  padding: var(--space-2);
  border-radius: var(--radius-md);
}

.btn-icon svg {
  width: 20px;
  height: 20px;
}


/* --- FORMS --- */

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.form-label {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text-secondary);
}

.form-input {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-base);
  color: var(--color-text);
  background-color: var(--color-input-bg);
  border: 1px solid var(--color-input-border);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input::placeholder {
  color: var(--color-text-muted);
}

.form-input:focus {
  border-color: var(--color-input-focus);
  box-shadow: 0 0 0 3px rgba(15, 52, 96, 0.12);
}

[data-theme="damas"] .form-input:focus {
  box-shadow: 0 0 0 3px rgba(183, 132, 167, 0.15);
}

.form-input.error {
  border-color: var(--color-error);
}

.form-input.error:focus {
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
}

.form-error {
  font-size: var(--text-xs);
  color: var(--color-error);
}

.form-hint {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

textarea.form-input {
  min-height: 100px;
  resize: vertical;
}

select.form-input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236E6E8A' d='M6 8.825a.5.5 0 0 1-.354-.146l-4-4a.5.5 0 1 1 .708-.708L6 7.617l3.646-3.646a.5.5 0 1 1 .708.708l-4 4A.5.5 0 0 1 6 8.825z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  padding-right: var(--space-8);
}

.form-check {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: var(--color-highlight);
  cursor: pointer;
}

.form-divider {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin: var(--space-6) 0;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.form-divider::before,
.form-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background-color: var(--color-border-light);
}


/* --- STATUS BADGES --- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  white-space: nowrap;
  line-height: 1.4;
}

.badge-pending {
  color: var(--status-pending);
  background-color: var(--status-pending-bg);
}

.badge-confirmed {
  color: var(--status-confirmed);
  background-color: var(--status-confirmed-bg);
}

.badge-cancelled {
  color: var(--status-cancelled);
  background-color: var(--status-cancelled-bg);
}

.badge-completed {
  color: var(--status-completed);
  background-color: var(--status-completed-bg);
}

.badge-no-show {
  color: var(--status-no-show);
  background-color: var(--status-no-show-bg);
}


/* --- TABLES --- */

.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table {
  width: 100%;
  font-size: var(--text-sm);
}

.table th {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  font-weight: var(--weight-semibold);
  color: var(--color-text-secondary);
  background-color: var(--color-surface-sunken);
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

.table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border-light);
  vertical-align: middle;
}

.table tr:hover td {
  background-color: var(--color-surface-sunken);
}


/* --- UTILITY CLASSES --- */

.hidden { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.gap-8 { gap: var(--space-8); }

.grid { display: grid; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

.w-full { width: 100%; }
.h-full { height: 100%; }

.m-0 { margin: 0; }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }

.p-2 { padding: var(--space-2); }
.p-3 { padding: var(--space-3); }
.p-4 { padding: var(--space-4); }
.p-6 { padding: var(--space-6); }
.px-4 { padding-left: var(--space-4); padding-right: var(--space-4); }
.py-2 { padding-top: var(--space-2); padding-bottom: var(--space-2); }
.py-4 { padding-top: var(--space-4); padding-bottom: var(--space-4); }

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rounded-sm { border-radius: var(--radius-sm); }
.rounded-md { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-full { border-radius: var(--radius-full); }

.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow-md { box-shadow: var(--shadow-md); }
.shadow-lg { box-shadow: var(--shadow-lg); }

.relative { position: relative; }
.absolute { position: absolute; }
.sticky { position: sticky; }

.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }

.cursor-pointer { cursor: pointer; }
.select-none { user-select: none; }
.pointer-events-none { pointer-events: none; }

.transition { transition: all var(--transition-base); }
.opacity-50 { opacity: 0.5; }
.opacity-0 { opacity: 0; }


/* --- MOBILE GRID OVERRIDE (1 col on mobile) --- */

@media (max-width: 639px) {
  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }
}

/* --- SMALL PHONE FIX (320-375px) --- */

@media (max-width: 375px) {
  .app-header {
    padding: 0 var(--space-2);
    gap: var(--space-2);
  }

  .header-title {
    font-size: var(--text-base);
  }

  .header-actions {
    gap: 0;
  }

  .lang-selector {
    padding: 4px 6px;
    font-size: 0.625rem;
  }

  .dark-mode-toggle,
  .header-action-btn {
    width: 32px;
    height: 32px;
  }

  .dark-mode-toggle svg,
  .header-action-btn svg {
    width: 18px;
    height: 18px;
  }

  .app-content {
    padding: var(--space-3);
  }
}


/* --- TABLET (640px+) --- */

@media (min-width: 640px) {
  .app-content {
    padding: var(--space-6);
  }

  h1 { font-size: var(--text-4xl); }
  h2 { font-size: var(--text-3xl); }
}


/* --- DESKTOP (1024px+) --- */

@media (min-width: 1024px) {
  .app-sidebar {
    transform: translateX(0);
  }

  .app-main {
    margin-left: var(--sidebar-width);
  }

  .app-footer {
    justify-content: flex-end;
  }

  .app-content {
    padding: var(--space-8);
  }

  .mobile-only {
    display: none !important;
  }
}

@media (max-width: 1023px) {
  .desktop-only {
    display: none !important;
  }
}
