/* Portal de Cliente — CSS Principal */
/* Implementado via CSS variables para extensibilidade de temas */

:root {
  --primary:       #3b82f6;
  --primary-dark:  #2563eb;
  --primary-light: #93c5fd;
  --bg:            #f8fafc;
  --surface:       #ffffff;
  --border:        #e2e8f0;
  --text:          #1e293b;
  --text-muted:    #64748b;
  --success:       #22c55e;
  --warning:       #f59e0b;
  --danger:        #ef4444;
  --sidebar-w:     260px;
  --header-h:      64px;
  --radius:        8px;
  --shadow:        0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:     0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.04);
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  :root.dark {
    --bg:      #0f172a;
    --surface: #1e293b;
    --border:  #334155;
    --text:    #f1f5f9;
    --text-muted: #94a3b8;
  }
}

:root.dark {
  --bg:      #0f172a;
  --surface: #1e293b;
  --border:  #334155;
  --text:    #f1f5f9;
  --text-muted: #94a3b8;
}

/* Themes */
:root[data-theme="green"]  { --primary: #16a34a; --primary-dark: #15803d; --primary-light: #86efac; }
:root[data-theme="purple"] { --primary: #9333ea; --primary-dark: #7e22ce; --primary-light: #d8b4fe; }
:root[data-theme="gray"]   { --primary: #475569; --primary-dark: #334155; --primary-light: #94a3b8; }
:root[data-theme="orange"] { --primary: #f97316; --primary-dark: #ea580c; --primary-light: #fdba74; }

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Layout */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform .25s ease;
}

.sidebar-logo {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: .75rem;
  min-height: var(--header-h);
}

.sidebar-logo img { height: 36px; object-fit: contain; }
.sidebar-logo-text { font-weight: 700; font-size: 1rem; color: var(--text); }

.sidebar-nav { flex: 1; overflow-y: auto; padding: .75rem 0; }

.sidebar-section {
  padding: .5rem 1.5rem .25rem;
  font-size: .65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .625rem 1.5rem;
  color: var(--text-muted);
  font-size: .9rem;
  transition: background .15s, color .15s;
  border-radius: 0;
}

.sidebar-link:hover, .sidebar-link.active {
  background: color-mix(in srgb, var(--primary) 8%, transparent);
  color: var(--primary);
  text-decoration: none;
}

.sidebar-link svg { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  font-size: .8rem;
  color: var(--text-muted);
}

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

.header {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow);
}

.header-title { font-size: 1rem; font-weight: 600; }

.header-actions { display: flex; align-items: center; gap: 1rem; }

.btn-icon {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  position: relative;
  transition: background .15s;
}
.btn-icon:hover { background: var(--border); }

.notification-badge {
  position: absolute;
  top: 2px; right: 2px;
  min-width: 16px; height: 16px;
  background: var(--danger);
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
  border-radius: 999px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 3px;
}

.user-menu {
  display: flex; align-items: center; gap: .5rem;
  cursor: pointer;
  padding: .375rem .75rem;
  border-radius: var(--radius);
  transition: background .15s;
}
.user-menu:hover { background: var(--border); }
.user-avatar {
  width: 32px; height: 32px;
  background: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: .8rem;
  font-weight: 700;
}

.page-content { padding: 1.5rem; flex: 1; }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.page-title { font-size: 1.25rem; font-weight: 700; }

/* Cards / Widgets */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: .75rem;
  border-bottom: 1px solid var(--border);
}

.card-title { font-size: 1rem; font-weight: 600; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.stat-value { font-size: 2rem; font-weight: 800; color: var(--primary); }
.stat-label { font-size: .85rem; color: var(--text-muted); margin-top: .25rem; }

/* Progress bar */
.progress-wrap { margin: .5rem 0; }
.progress-label {
  display: flex; justify-content: space-between;
  font-size: .8rem; color: var(--text-muted);
  margin-bottom: .25rem;
}
.progress-bar { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 4px; background: var(--primary); transition: width .3s; }
.progress-fill.warn   { background: var(--warning); }
.progress-fill.danger { background: var(--danger); }

/* Alert banners */
.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: .9rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.alert-error   { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.alert-warning { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.alert-info    { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem 1rem;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .15s, opacity .15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { opacity: .9; text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-danger  { background: var(--danger);  color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-sm { padding: .35rem .75rem; font-size: .8rem; }
.btn-xs { padding: .2rem .5rem; font-size: .75rem; }

/* Forms */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: .875rem; font-weight: 500; margin-bottom: .35rem; }
.form-control {
  width: 100%;
  padding: .5rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .9rem;
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent);
}
.form-text { font-size: .8rem; color: var(--text-muted); margin-top: .25rem; }
.form-row { display: grid; gap: 1rem; }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }

select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23475569' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e"); background-repeat: no-repeat; background-position: right .75rem center; background-size: 16px 12px; padding-right: 2.5rem; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
thead th { text-align: left; padding: .75rem 1rem; font-weight: 600; color: var(--text-muted); border-bottom: 2px solid var(--border); white-space: nowrap; }
tbody td { padding: .75rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: color-mix(in srgb, var(--primary) 4%, transparent); }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: .2rem .6rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
}
.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef9c3; color: #854d0e; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-info    { background: #dbeafe; color: #1e40af; }
.badge-gray    { background: var(--border); color: var(--text-muted); }

/* Kanban */
.kanban-board {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  padding-bottom: 1rem;
  min-height: 60vh;
  align-items: flex-start;
}

.kanban-column {
  min-width: 280px;
  max-width: 280px;
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.kanban-col-header {
  padding: .75rem 1rem;
  font-weight: 600;
  font-size: .9rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.kanban-col-body {
  flex: 1;
  padding: .75rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  min-height: 100px;
}

.kanban-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem;
  cursor: grab;
  box-shadow: var(--shadow);
  transition: box-shadow .15s;
}

.kanban-card:hover { box-shadow: var(--shadow-md); }
.kanban-card.dragging { opacity: .5; }

.kanban-card-title { font-weight: 600; font-size: .875rem; margin-bottom: .25rem; }
.kanban-card-meta { font-size: .75rem; color: var(--text-muted); }

/* Notifications panel */
.notif-panel {
  position: absolute;
  right: 0; top: calc(100% + .5rem);
  width: 320px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  z-index: 200;
  overflow: hidden;
}

.notif-item {
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: .85rem;
}
.notif-item:last-child { border-bottom: none; }
.notif-item.unread { background: color-mix(in srgb, var(--primary) 5%, transparent); }
.notif-time { font-size: .75rem; color: var(--text-muted); }

/* Toast */
.toast-container {
  position: fixed;
  bottom: 1.5rem; right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  z-index: 9999;
}

.toast {
  padding: .75rem 1.25rem;
  border-radius: var(--radius);
  background: var(--text);
  color: var(--surface);
  font-size: .875rem;
  box-shadow: var(--shadow-md);
  animation: slideIn .2s ease;
  max-width: 320px;
}

.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }
.toast.warning { background: var(--warning); color: #000; }

@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Auth pages */
.auth-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 1rem;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) * 1.5);
  padding: 2rem;
  box-shadow: var(--shadow-md);
}

.auth-logo { text-align: center; margin-bottom: 1.5rem; }
.auth-title { font-size: 1.375rem; font-weight: 800; text-align: center; margin-bottom: .25rem; }
.auth-subtitle { text-align: center; color: var(--text-muted); font-size: .9rem; margin-bottom: 1.5rem; }

/* Responsive */
.hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text);
  padding: .5rem;
}

.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 99;
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: 4px 0 20px rgba(0,0,0,.2); }
  .overlay.show { display: block; }
  .main { margin-left: 0; }
  .hamburger { display: flex; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .form-row.cols-2, .form-row.cols-3 { grid-template-columns: 1fr; }
  .kanban-board { flex-direction: column; }
  .kanban-column { min-width: 100%; max-width: 100%; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
}

/* Utility */
.text-muted   { color: var(--text-muted); }
.text-danger  { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.mt-1 { margin-top: .25rem; }
.mt-2 { margin-top: .5rem; }
.mt-4 { margin-top: 1rem; }
.mb-4 { margin-bottom: 1rem; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: .5rem; }
.gap-4 { gap: 1rem; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
