/* =========================================================
   FROTA — CSS Moderno Responsivo (Mobile-First)
   ========================================================= */

*,*::before,*::after { box-sizing: border-box; }

:root{
  /* Cores */
  --bg-0:        #0a0f1c;
  --bg-1:        #0f172a;
  --bg-2:        #131c33;
  --surface:     #18223f;
  --surface-hi:  #1f2c52;
  --line:        #243056;
  --line-soft:   #1a2444;
  --text:        #e7ecf7;
  --text-dim:    #a3aed6;
  --text-mute:   #6c789c;

  /* Marca */
  --brand:       #3b82f6;
  --brand-hi:    #60a5fa;
  --brand-soft:  rgba(59,130,246,.15);

  /* Estados */
  --ok:          #22c55e;
  --ok-soft:     rgba(34,197,94,.15);
  --warn:        #f59e0b;
  --warn-soft:   rgba(245,158,11,.15);
  --danger:      #ef4444;
  --danger-soft: rgba(239,68,68,.15);
  --info:        #06b6d4;
  --info-soft:   rgba(6,182,212,.15);

  /* Sombras / raios */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.2);
  --shadow-md: 0 4px 16px rgba(0,0,0,.25);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.35);

  /* Layout */
  --sidebar-w: 240px;
  --topbar-h: 60px;
}

html, body { margin:0; padding:0; }
body{
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg-0);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--brand-hi); text-decoration: none; }
a:hover { color: var(--brand); }
img { max-width: 100%; height: auto; display: block; }

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

/* Sidebar */
.sidebar{
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--bg-1), var(--bg-0));
  border-right: 1px solid var(--line);
  position: fixed; top: 0; left: 0; bottom: 0;
  display: flex; flex-direction: column;
  z-index: 50;
  transform: translateX(-100%);
  transition: transform .25s ease;
}
.sidebar.open { transform: translateX(0); }
.sidebar-header{
  height: var(--topbar-h);
  padding: 0 18px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--line);
}
.brand-logo{
  width: 32px; height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--brand), var(--info));
  display: grid; place-items: center;
  font-weight: 800; color: white;
  box-shadow: var(--shadow-sm);
}
.brand-name{ font-weight: 700; font-size: 16px; letter-spacing: .3px; }
.sidebar-nav{
  flex: 1; padding: 12px 10px;
  overflow-y: auto;
}
.nav-section{
  font-size: 11px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--text-mute); padding: 12px 12px 6px;
}
.nav-item{
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  color: var(--text-dim);
  border-radius: var(--r-sm);
  font-size: 14px; font-weight: 500;
  transition: background .15s, color .15s;
  margin-bottom: 2px;
}
.nav-item:hover{ background: var(--surface); color: var(--text); }
.nav-item.active{
  background: var(--brand-soft);
  color: var(--brand-hi);
  box-shadow: inset 3px 0 0 var(--brand);
}
.nav-item .ico{
  width: 18px; height: 18px;
  flex-shrink: 0;
  opacity: .9;
}
.sidebar-footer{
  border-top: 1px solid var(--line);
  padding: 14px;
  font-size: 12px;
  color: var(--text-mute);
}
.user-mini{
  display: flex; align-items: center; gap: 10px;
}
.user-avatar{
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--info));
  display: grid; place-items: center;
  font-weight: 700; color: white;
  flex-shrink: 0;
}
.user-info{ min-width: 0; flex: 1; }
.user-name{ color: var(--text); font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role{ font-size: 11px; color: var(--text-mute); text-transform: uppercase; letter-spacing: .5px; }

/* Backdrop mobile */
.sidebar-backdrop{
  position: fixed; inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 49;
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
.sidebar-backdrop.show{ opacity: 1; pointer-events: auto; }

/* Main */
.main{
  flex: 1;
  min-width: 0;
  display: flex; flex-direction: column;
  margin-left: 0;
}
.topbar{
  height: var(--topbar-h);
  background: rgba(15,23,42,.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 0 16px;
  display: flex; align-items: center; gap: 12px;
  position: sticky; top: 0; z-index: 40;
}
.menu-toggle{
  width: 40px; height: 40px;
  border-radius: var(--r-sm);
  background: var(--surface);
  border: 1px solid var(--line);
  display: grid; place-items: center;
  cursor: pointer;
  color: var(--text);
}
.menu-toggle:hover{ background: var(--surface-hi); }
.topbar-title{ font-weight: 600; font-size: 16px; }
.topbar-spacer{ flex: 1; }
.topbar-actions{ display: flex; gap: 8px; align-items: center; }

.content{
  padding: 18px 14px 60px;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}

/* Desktop */
@media (min-width: 900px){
  .sidebar{ transform: translateX(0); }
  .sidebar-backdrop{ display: none; }
  .main{ margin-left: var(--sidebar-w); }
  .menu-toggle{ display: none; }
  .content{ padding: 24px 28px 60px; }
}

/* ================= CARDS ================= */
.card{
  background: linear-gradient(180deg, var(--surface), var(--bg-2));
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.card.compact{ padding: 14px; }
.card h1, .card h2, .card h3 { margin: 0 0 12px; }
.card h1 { font-size: 22px; font-weight: 700; }
.card h2 { font-size: 18px; font-weight: 600; }
.card h3 { font-size: 15px; font-weight: 600; color: var(--text-dim); }
.card .subtitle{ color: var(--text-mute); font-size: 13px; margin: -8px 0 14px; }

/* Stat cards (dashboard) */
.stat-grid{
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 12px;
  margin-bottom: 18px;
}
@media (min-width: 700px){
  .stat-grid{ grid-template-columns: repeat(4, minmax(0,1fr)); }
}
.stat-card{
  background: linear-gradient(135deg, var(--surface), var(--bg-2));
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px;
  position: relative;
  overflow: hidden;
}
.stat-card .stat-label{ color: var(--text-mute); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }
.stat-card .stat-value{ font-size: 28px; font-weight: 800; margin: 6px 0 4px; }
.stat-card .stat-hint{ color: var(--text-dim); font-size: 12px; }
.stat-card .stat-icon{
  position: absolute; right: 14px; top: 14px;
  width: 36px; height: 36px;
  border-radius: 10px;
  display: grid; place-items: center;
  opacity: .9;
}
.stat-card.brand .stat-icon{ background: var(--brand-soft); color: var(--brand-hi); }
.stat-card.ok .stat-icon{ background: var(--ok-soft); color: var(--ok); }
.stat-card.warn .stat-icon{ background: var(--warn-soft); color: var(--warn); }
.stat-card.danger .stat-icon{ background: var(--danger-soft); color: var(--danger); }
.stat-card.info .stat-icon{ background: var(--info-soft); color: var(--info); }

/* ================= GRID ================= */
.row{ display: grid; grid-template-columns: 1fr; gap: 14px; }
.row.cols-2 { grid-template-columns: 1fr; }
.row.cols-3 { grid-template-columns: 1fr; }
@media (min-width: 700px){
  .row.cols-2 { grid-template-columns: 1fr 1fr; }
  .row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
}
.col{ min-width: 0; }
.flex{ display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.flex-between{ display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.spacer{ flex: 1; }

/* ================= FORMS ================= */
label{
  display: block;
  margin: 12px 0 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
}
input[type="text"], input[type="number"], input[type="email"], input[type="password"],
input[type="date"], input[type="tel"], input[type="search"], input[type="url"],
input[type="file"], select, textarea{
  width: 100%;
  padding: 11px 13px;
  font-size: 15px;
  font-family: inherit;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--text);
  transition: border-color .15s, box-shadow .15s, background .15s;
  -webkit-appearance: none;
  appearance: none;
}
input:focus, select:focus, textarea:focus{
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
  background: var(--bg-2);
}
input[type="file"]{ padding: 9px 11px; }
textarea{ min-height: 90px; resize: vertical; }
select{
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23a3aed6' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}
input::placeholder, textarea::placeholder { color: var(--text-mute); }

/* Checkbox / radio */
input[type="checkbox"], input[type="radio"]{
  width: 18px; height: 18px;
  accent-color: var(--brand);
  cursor: pointer;
}
.check-row{
  display: flex; align-items: center; gap: 10px;
  margin: 8px 0;
  cursor: pointer;
  user-select: none;
}
.check-row label{ margin: 0; cursor: pointer; }

.field-help{ font-size: 12px; color: var(--text-mute); margin-top: 4px; }
.field-error{ font-size: 13px; color: var(--danger); margin-top: 4px; }

/* ================= BUTTONS ================= */
.btn{
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  font-size: 14px; font-weight: 600;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover{ background: var(--surface-hi); border-color: var(--brand); color: var(--text); }
.btn:active{ transform: translateY(1px); }
.btn:disabled{ opacity: .55; cursor: not-allowed; }
.btn.primary{
  background: linear-gradient(135deg, var(--brand), #2563eb);
  border-color: transparent;
  color: white;
  box-shadow: 0 4px 12px rgba(59,130,246,.25);
}
.btn.primary:hover{
  background: linear-gradient(135deg, var(--brand-hi), var(--brand));
  color: white;
}
.btn.success{ background: var(--ok); border-color: transparent; color: #052e16; }
.btn.success:hover{ background: #16a34a; color: #052e16; }
.btn.danger{ background: var(--danger); border-color: transparent; color: #450a0a; }
.btn.danger:hover{ background: #dc2626; color: #450a0a; }
.btn.ghost{ background: transparent; }
.btn.sm{ padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn.lg{ padding: 14px 22px; font-size: 16px; }
.btn.full{ width: 100%; }

.btn-group{ display: inline-flex; flex-wrap: wrap; gap: 8px; }

/* ================= TABLES ================= */
.table-wrap{
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.table{
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.table thead{ background: var(--bg-2); }
.table th{
  text-align: left;
  padding: 12px 14px;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-mute);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td{
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
.table tbody tr:last-child td{ border-bottom: none; }
.table tbody tr:hover{ background: rgba(59,130,246,.05); }
.table .text-right { text-align: right; }
.table .nowrap { white-space: nowrap; }
.table .small-col { width: 1%; white-space: nowrap; }

/* Tabela responsiva: vira lista de cards no mobile */
@media (max-width: 720px){
  .table.responsive thead{ display: none; }
  .table.responsive, .table.responsive tbody, .table.responsive tr, .table.responsive td{ display: block; width: 100%; }
  .table.responsive tr{
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: 8px 4px;
    margin-bottom: 10px;
  }
  .table.responsive tr:hover{ background: var(--surface); }
  .table.responsive td{
    border: none;
    padding: 8px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
  }
  .table.responsive td::before{
    content: attr(data-label);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-mute);
    font-weight: 600;
    flex-shrink: 0;
  }
  .table.responsive td.actions{
    justify-content: flex-end;
    border-top: 1px solid var(--line-soft);
    margin-top: 4px;
    padding-top: 12px;
  }
  .table.responsive td.actions::before{ display: none; }
}

.empty-state{
  padding: 40px 20px;
  text-align: center;
  color: var(--text-mute);
}
.empty-state .ico{
  width: 48px; height: 48px;
  margin: 0 auto 12px;
  opacity: .5;
}

/* ================= BADGES ================= */
.badge{
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: var(--surface);
  color: var(--text-dim);
}
.badge.ok       { background: var(--ok-soft);     color: var(--ok);     border-color: rgba(34,197,94,.3); }
.badge.warn     { background: var(--warn-soft);   color: var(--warn);   border-color: rgba(245,158,11,.3); }
.badge.danger   { background: var(--danger-soft); color: var(--danger); border-color: rgba(239,68,68,.3); }
.badge.info     { background: var(--info-soft);   color: var(--info);   border-color: rgba(6,182,212,.3); }
.badge.brand    { background: var(--brand-soft);  color: var(--brand-hi); border-color: rgba(59,130,246,.3); }
.badge .dot{ width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ================= NOTICES / ALERTS ================= */
.notice{
  padding: 12px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-dim);
  font-size: 14px;
  display: flex; align-items: flex-start; gap: 10px;
  margin-bottom: 12px;
}
.notice.success{ background: var(--ok-soft);     border-color: rgba(34,197,94,.3);  color: var(--ok); }
.notice.warn   { background: var(--warn-soft);   border-color: rgba(245,158,11,.3); color: var(--warn); }
.notice.danger { background: var(--danger-soft); border-color: rgba(239,68,68,.3);  color: var(--danger); }
.notice.info   { background: var(--info-soft);   border-color: rgba(6,182,212,.3);  color: var(--info); }
.notice .ico{ width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }

/* ================= UTILITIES ================= */
.small{ font-size: 12px; color: var(--text-mute); }
.muted{ color: var(--text-mute); }
.dim{ color: var(--text-dim); }
.bold{ font-weight: 700; }
.center{ text-align: center; }
.mt-0{margin-top:0;} .mt-1{margin-top:8px;} .mt-2{margin-top:14px;} .mt-3{margin-top:20px;}
.mb-0{margin-bottom:0;} .mb-1{margin-bottom:8px;} .mb-2{margin-bottom:14px;} .mb-3{margin-bottom:20px;}
.hide-mobile{ display: none; }
.show-mobile{ display: initial; }
@media (min-width: 700px){
  .hide-mobile{ display: initial; }
  .show-mobile{ display: none; }
}

/* Definition list (key/value pairs) */
.kv{
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
@media (min-width: 600px){
  .kv{ grid-template-columns: repeat(2, minmax(0,1fr)); }
  .kv.cols-3{ grid-template-columns: repeat(3, minmax(0,1fr)); }
}
.kv-item .k{ font-size: 11px; text-transform: uppercase; color: var(--text-mute); font-weight: 700; letter-spacing: .5px; margin-bottom: 2px; }
.kv-item .v{ font-size: 15px; color: var(--text); font-weight: 500; }

/* Login page */
.login-shell{
  min-height: 100vh;
  display: grid; place-items: center;
  padding: 20px;
  background:
    radial-gradient(circle at 20% 10%, rgba(59,130,246,.18), transparent 40%),
    radial-gradient(circle at 80% 90%, rgba(6,182,212,.12), transparent 40%),
    var(--bg-0);
}
.login-card{
  width: 100%; max-width: 400px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  padding: 28px;
  box-shadow: var(--shadow-lg);
}
.login-card .brand-logo{
  width: 56px; height: 56px;
  margin: 0 auto 16px;
  font-size: 24px;
  border-radius: 14px;
}
.login-card h1{ text-align: center; margin: 0 0 6px; font-size: 22px; }
.login-card .subtitle{ text-align: center; }

/* File input nicer */
input[type="file"]::file-selector-button{
  background: var(--brand-soft); color: var(--brand-hi);
  border: none; padding: 6px 12px; border-radius: 8px;
  font-weight: 600; cursor: pointer; margin-right: 10px;
}
input[type="file"]::-webkit-file-upload-button{
  background: var(--brand-soft); color: var(--brand-hi);
  border: none; padding: 6px 12px; border-radius: 8px;
  font-weight: 600; cursor: pointer; margin-right: 10px;
}

/* Scrollbar suave */
::-webkit-scrollbar{ width: 10px; height: 10px; }
::-webkit-scrollbar-thumb{ background: var(--surface-hi); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover{ background: var(--brand); }
::-webkit-scrollbar-track{ background: transparent; }

/* Foto preview */
.photo-grid{
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
  margin-top: 10px;
}
.photo-grid a{
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 12px 8px;
  text-align: center;
  font-size: 13px;
  color: var(--text-dim);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  transition: border-color .15s, transform .1s;
}
.photo-grid a:hover{ border-color: var(--brand); color: var(--brand-hi); transform: translateY(-1px); }
.photo-grid a .ico{ width: 28px; height: 28px; opacity: .8; }

/* Skeleton para loading */
.skeleton{
  background: linear-gradient(90deg, var(--surface) 0%, var(--surface-hi) 50%, var(--surface) 100%);
  background-size: 200% 100%;
  animation: skeleton 1.4s ease infinite;
  border-radius: var(--r-sm);
}
@keyframes skeleton{ 0%{background-position:200% 0;} 100%{background-position:-200% 0;} }

/* Fab (mobile) */
.fab{
  position: fixed;
  right: 18px; bottom: 18px;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), #2563eb);
  color: white;
  display: grid; place-items: center;
  box-shadow: 0 8px 24px rgba(59,130,246,.45);
  z-index: 30;
  border: none;
  font-size: 24px;
  cursor: pointer;
}
.fab:hover{ transform: scale(1.05); }

/* Print */
@media print{
  .sidebar, .topbar, .menu-toggle, .btn { display: none !important; }
  .main { margin-left: 0; }
  .card { box-shadow: none; border: 1px solid #ccc; }
  body { background: white; color: black; }
}
