@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
@import 'reset.css';
@import 'status.css';

/* ── Variables ──────────────────────────────────────────────────────────── */
:root {
  --primary: #c4578a;
  --primary-light: #e87fb5;
  --primary-dark: #9b3d6b;
  --primary-bg: #fce7f3;
  --accent: #f0c178;
  --bg: #fdf6f9;
  --surface: #ffffff;
  --surface2: #faf5f8;
  --sidebar-bg: #1e0f1a;
  --sidebar-hover: #2d1826;
  --sidebar-active: #c4578a;
  --sidebar-text: #d4b8cc;
  --sidebar-text-active: #ffffff;
  --text: #1e0f1a;
  --text-muted: #7a5d70;
  --border: #e8d5e2;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
  --radius: 10px;
  --radius-sm: 6px;
  --sidebar-width: 230px;
  --header-height: 60px;
  --transition: 150ms ease;
}

/* ── Base ────────────────────────────────────────────────────────────────── */
html,
body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
}

/* ── Layout ─────────────────────────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
  width: 100%;
  min-width: 0;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
  transition: transform var(--transition);
}

.sidebar-logo {
  padding: 20px 16px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}
.sidebar-logo-icon {
  width: 34px; height: 34px;
  background: var(--primary);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.sidebar-logo-text { color: #fff; font-size: 0.85rem; font-weight: 600; line-height: 1.2; }
.sidebar-logo-text span { display: block; color: var(--sidebar-text); font-weight: 400; font-size: 0.72rem; }

.sidebar-section { padding: 12px 8px 4px; }
.sidebar-section-label { color: rgba(255,255,255,0.3); font-size: 0.65rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; padding: 0 8px 6px; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  font-size: 0.84rem; font-weight: 500;
  transition: background var(--transition), color var(--transition);
  cursor: pointer;
  margin-bottom: 1px;
}
.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-item .nav-icon { width: 18px; height: 18px; opacity: 0.8; flex-shrink: 0; }
.nav-item.active .nav-icon { opacity: 1; }

.sidebar-footer {
  margin-top: auto;
  padding: 12px 8px;
  border-top: 1px solid rgba(255,255,255,0.07);
}
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
}
.sidebar-user:hover { background: var(--sidebar-hover); }
.sidebar-user-avatar {
  width: 32px; height: 32px;
  background: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 0.8rem;
  flex-shrink: 0;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name { color: #fff; font-size: 0.8rem; font-weight: 600; truncate: true; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { color: var(--sidebar-text); font-size: 0.7rem; }
.sidebar-logout { color: var(--sidebar-text); opacity: 0.7; font-size: 0.75rem; padding: 4px 12px; cursor: pointer; }
.sidebar-logout:hover { color: #fff; opacity: 1; }

/* ── Main content ────────────────────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
}

.page-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}
.page-title { font-size: 1.05rem; font-weight: 700; }
.page-header-actions { display: flex; align-items: center; gap: 10px; }

.page-body { padding: 24px; flex: 1; }

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-title { font-size: 0.9rem; font-weight: 600; }
.card-subtitle { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.84rem; font-weight: 500;
  transition: all var(--transition);
  white-space: nowrap;
  cursor: pointer;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: var(--surface2); border-color: var(--primary); color: var(--primary); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface2); color: var(--text); }
.btn-danger { background: #fee2e2; color: #991b1b; }
.btn-danger:hover { background: #fecaca; }
.btn-success { background: #dcfce7; color: #166534; }
.btn-success:hover { background: #bbf7d0; }
.btn-sm { padding: 5px 10px; font-size: 0.78rem; }
.btn-lg { padding: 11px 22px; font-size: 0.95rem; }
.btn-icon { padding: 7px; border-radius: var(--radius-sm); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; letter-spacing: 0.02em; }
.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 0.87rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(196,87,138,0.12); }
.form-control::placeholder { color: #b0909f; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.form-hint { font-size: 0.74rem; color: var(--text-muted); margin-top: 4px; }
.dias-trabalho {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.dia-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 0.84rem;
  cursor: pointer;
}
.dia-checkbox input {
  flex-shrink: 0;
  accent-color: var(--primary);
}

/* ── Tables ───────────────────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
.table { width: 100%; min-width: 720px; background: var(--surface); }
.table th {
  padding: 11px 14px;
  text-align: left;
  font-size: 0.73rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #fdf0f6; }
.table-empty { text-align: center; color: var(--text-muted); padding: 40px; font-size: 0.85rem; }

/* ── Search bar ──────────────────────────────────────────────────────────── */
.search-bar { position: relative; }
.search-bar input { padding-left: 36px; }
.search-bar .search-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); pointer-events: none;
  width: 16px; height: 16px;
}

/* ── Stat cards ──────────────────────────────────────────────────────────── */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.stat-card-label { font-size: 0.75rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 6px; }
.stat-card-value { font-size: 1.6rem; font-weight: 700; color: var(--text); line-height: 1; }
.stat-card-sub { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }
.stat-card-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
}

/* ── Dashboard & Action Cards ────────────────────────────────────────────── */
.dashboard-container { display: flex; flex-direction: column; gap: 20px; }
.quick-actions { display: flex; flex-direction: column; gap: 10px; }
.stat-card-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.card-action {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  transition: transform var(--transition);
}
.card-action:hover { border-color: var(--primary); }
.card-action-info .name { font-weight: 700; font-size: 0.95rem; }
.card-action-info .details { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }
.card-action-buttons { display: flex; gap: 8px; }

/* ── Utils ────────────────────────────────────────────────────────────────── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.8rem; }
.text-xs { font-size: 0.72rem; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.mt-4 { margin-top: 16px; }
.w-full { width: 100%; }

/* ── Toast ────────────────────────────────────────────────────────────────── */
#toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 0.85rem; font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.25s ease;
  max-width: 340px;
}
.toast-success { background: #166534; color: white; }
.toast-error   { background: #991b1b; color: white; }
.toast-info    { background: var(--primary-dark); color: white; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── Loading ─────────────────────────────────────────────────────────────── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay {
  position: fixed; inset: 0; background: rgba(255,255,255,0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 9998;
}

/* ── Divider ─────────────────────────────────────────────────────────────── */
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* ── Avatar ──────────────────────────────────────────────────────────────── */
.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem; font-weight: 700; color: white;
  flex-shrink: 0;
}

/* ── Mobile toggle button ────────────────────────────────────────────────── */
.mobile-toggle {
  display: none;
  padding: 10px;
  border-radius: var(--radius-sm);
  font-size: 20px;
  line-height: 1;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text);
  min-width: 44px; min-height: 44px;
  align-items: center; justify-content: center;
}

/* ── Sidebar overlay backdrop ────────────────────────────────────────────── */
.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 99;
  backdrop-filter: blur(1px);
}
.sidebar-backdrop.open { display: block; }

/* ── Bottom navigation bar (mobile only) ────────────────────────────────── */
.bottom-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--sidebar-bg);
  padding: 6px 0 env(safe-area-inset-bottom, 6px);
  z-index: 98;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.2);
}
.bottom-nav-items {
  display: flex;
  justify-content: space-around;
  align-items: center;
}
.bottom-nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 12px;
  color: var(--sidebar-text);
  font-size: 0.62rem; font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  min-width: 54px; min-height: 50px;
  justify-content: center;
  border-radius: 8px;
  transition: color 0.15s, background 0.15s;
}
.bottom-nav-item .bn-icon { font-size: 20px; line-height: 1; }
.bottom-nav-item.active { color: var(--primary-light); }
.bottom-nav-item:active { background: rgba(255,255,255,0.08); }

/* ── Responsive breakpoints ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Sidebar as drawer */
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 100;
  }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,0.3); }

  /* No left margin on mobile */
  .main-content { margin-left: 0; padding-bottom: 66px; }

  /* Show hamburger & bottom nav */
  .mobile-toggle { display: flex; }
  .bottom-nav { display: block; }

  /* Grids collapse */
  .grid-4 { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .grid-3 { grid-template-columns: 1fr 1fr; gap: 10px; }

  /* Page body padding */
  .page-body { padding: 12px; }

  /* Forms always single column */
  .form-row, .form-row-3 { grid-template-columns: 1fr; gap: 0; }

  /* Inputs: 16px font prevents iOS auto-zoom */
  .form-control { font-size: 16px !important; padding: 11px 14px; min-height: 44px; }
  select.form-control { min-height: 44px; }

  /* Larger button touch targets */
  .btn { min-height: 42px; padding: 10px 16px; }
  .btn-sm { min-height: 36px; padding: 7px 12px; font-size: 0.8rem; }

  /* Page header compact */
  .page-header { padding: 0 12px; height: 54px; }
  .page-title { font-size: 0.95rem; }

  /* Card padding tighter */
  .card { padding: 14px; }
  .card-header { flex-direction: column; align-items: flex-start; gap: 10px; }

  /* Stat cards compact */
  .stat-card { padding: 14px 16px; }
  .stat-card-value { font-size: 1.35rem; }

  /* Table: horizontal scroll */
  .table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table th, .table td { padding: 10px 12px; font-size: 0.8rem; white-space: nowrap; }

  /* Toast: full width at bottom */
  #toast-container { bottom: 76px; left: 12px; right: 12px; }
  .toast { max-width: 100%; }
}

@media (max-width: 480px) {
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .page-header-actions .btn span { display: none; } /* hide text in header btns, show icon only */
}

/* ── Touch-friendly table cards (mobile) ─────────────────────────────────── */
@media (max-width: 600px) {
  /* Hide less important table columns */
  .hide-mobile { display: none !important; }
}

/* ── Prevent text size adjustment on iOS ─────────────────────────────────── */
@media screen {
  * { -webkit-tap-highlight-color: rgba(196,87,138,0.15); }
}
