/* ============================================================
   JMF MADEIRAS — ADMIN PANEL CSS
   Paleta: Sidebar #1A0A05 | Accent #C62828 | Cards branco
   ============================================================ */

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

/* ─── RESET & BASE ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --sidebar-bg:    #1A0A05;
  --sidebar-w:     260px;
  --accent:        #C62828;
  --accent-dark:   #a01f1f;
  --accent-light:  #ffebee;
  --white:         #ffffff;
  --surface:       #f7f7f8;
  --card:          #ffffff;
  --border:        #e8e8e8;
  --text-primary:  #1A1A1A;
  --text-secondary:#757575;
  --text-muted:    #aaaaaa;
  --success:       #2e7d32;
  --warning:       #e65100;
  --danger:        #c62828;
  --info:          #1565c0;
  --header-h:      68px;
  --radius:        10px;
  --shadow:        0 2px 12px rgba(0,0,0,.08);
  --shadow-md:     0 4px 24px rgba(0,0,0,.12);
  --transition:    .22s cubic-bezier(.4,0,.2,1);
  --font:          'Inter', sans-serif;
}

html { font-size: 15px; }

body {
  font-family: var(--font);
  background: var(--surface);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

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

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}

.sidebar-brand-icon {
  width: 40px; height: 40px;
  background: var(--accent);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: #fff;
  flex-shrink: 0;
}

.sidebar-brand-text {
  line-height: 1.2;
}
.sidebar-brand-text strong {
  display: block;
  font-size: .95rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: .3px;
}
.sidebar-brand-text span {
  font-size: .72rem;
  color: rgba(255,255,255,.45);
  font-weight: 400;
  letter-spacing: .5px;
  text-transform: uppercase;
}

/* Nav groups */
.sidebar-nav {
  flex: 1;
  padding: 10px 0 12px;
}

.sidebar-section-label {
  font-size: .66rem;
  font-weight: 600;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: rgba(255,255,255,.28);
  padding: 14px 22px 6px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  margin: 1px 10px;
  border-radius: 8px;
  font-size: .88rem;
  font-weight: 500;
  color: rgba(255,255,255,.65);
  transition: background var(--transition), color var(--transition);
  position: relative;
}

.sidebar-nav a i {
  width: 20px;
  text-align: center;
  font-size: .9rem;
  flex-shrink: 0;
}

.sidebar-nav a:hover {
  background: rgba(255,255,255,.07);
  color: rgba(255,255,255,.95);
}

.sidebar-nav a.active {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

.sidebar-nav a.active i { color: #fff; }

/* Back to site link */
.sidebar-footer {
  padding: 12px 10px 20px;
  border-top: 1px solid rgba(255,255,255,.07);
}

.sidebar-footer a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: .83rem;
  font-weight: 500;
  color: rgba(255,255,255,.5);
  border: 1px solid rgba(255,255,255,.1);
  transition: all var(--transition);
}
.sidebar-footer a:hover {
  color: #fff;
  border-color: rgba(255,255,255,.25);
  background: rgba(255,255,255,.06);
}
.sidebar-footer a i { font-size: .85rem; }

/* Toggle sidebar button (mobile) */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: 16px; left: 16px;
  z-index: 300;
  background: var(--accent);
  border: none;
  color: #fff;
  width: 40px; height: 40px;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

/* ─── MAIN AREA ─────────────────────────────────────────────── */
.admin-main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition);
}

/* ─── HEADER ────────────────────────────────────────────────── */
.admin-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 6px rgba(0,0,0,.06);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 16px;
}

.admin-header h1 {
  flex: 1;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -.2px;
}

.admin-header-user {
  display: flex;
  align-items: center;
  gap: 14px;
}

.admin-header-user span {
  font-size: .85rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.btn-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-secondary);
  font-size: .9rem;
  transition: all var(--transition);
}
.btn-logout:hover {
  background: var(--accent-light);
  color: var(--accent);
}

/* ─── CONTENT AREA ──────────────────────────────────────────── */
.admin-content {
  flex: 1;
  padding: 28px;
}

/* ─── CARDS ─────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

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

.card-header h2, .card-header h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.card-body { padding: 22px; }

/* ─── STAT CARDS (Dashboard) ────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 24px;
  display: flex;
  align-items: center;
  gap: 18px;
  transition: box-shadow var(--transition), transform var(--transition);
}
.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.stat-icon {
  width: 52px; height: 52px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}
.stat-icon.red    { background: #ffebee; color: #c62828; }
.stat-icon.green  { background: #e8f5e9; color: #2e7d32; }
.stat-icon.blue   { background: #e3f2fd; color: #1565c0; }
.stat-icon.orange { background: #fff3e0; color: #e65100; }
.stat-icon.purple { background: #f3e5f5; color: #6a1b9a; }

.stat-info {}
.stat-info small {
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--text-muted);
}
.stat-info strong {
  display: block;
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.1;
  margin-top: 2px;
}

/* ─── GRID LAYOUT ───────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 22px; }

/* ─── TABLES ────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .87rem;
}

thead tr {
  background: var(--surface);
}

thead th {
  padding: 12px 16px;
  text-align: left;
  font-size: .73rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #fafafa; }

tbody td {
  padding: 13px 16px;
  color: var(--text-primary);
  vertical-align: middle;
}

/* ─── BADGES ────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .3px;
}
.badge-success { background: #e8f5e9; color: #2e7d32; }
.badge-danger  { background: #ffebee; color: #c62828; }
.badge-warning { background: #fff3e0; color: #e65100; }
.badge-info    { background: #e3f2fd; color: #1565c0; }
.badge-neutral { background: #f5f5f5; color: #757575; }

/* ─── BUTTONS ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: 8px;
  font-family: var(--font);
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
}

.btn-primary   { background: var(--accent); color: #fff; }
.btn-primary:hover   { background: var(--accent-dark); box-shadow: 0 4px 14px rgba(198,40,40,.35); }

.btn-secondary { background: var(--surface); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover { background: #efefef; }

.btn-success   { background: #2e7d32; color: #fff; }
.btn-success:hover   { background: #1b5e20; }

.btn-danger    { background: #c62828; color: #fff; }
.btn-danger:hover    { background: #a01f1f; }

.btn-warning   { background: #e65100; color: #fff; }
.btn-warning:hover   { background: #bf360c; }

.btn-info      { background: #1565c0; color: #fff; }
.btn-info:hover      { background: #0d47a1; }

.btn-sm { padding: 6px 12px; font-size: .78rem; border-radius: 6px; }
.btn-xs { padding: 4px 9px;  font-size: .72rem; border-radius: 5px; }
.btn-icon { padding: 8px; width: 34px; height: 34px; justify-content: center; }

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

/* ─── FORMS ─────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  letter-spacing: .2px;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-family: var(--font);
  font-size: .88rem;
  color: var(--text-primary);
  background: #fff;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(198,40,40,.12);
}
.form-control::placeholder { color: var(--text-muted); }

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

select.form-control { cursor: pointer; }

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.form-hint {
  font-size: .73rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ─── ALERTS ────────────────────────────────────────────────── */
.alert {
  padding: 13px 18px;
  border-radius: 8px;
  font-size: .88rem;
  font-weight: 500;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.alert-success { background: #e8f5e9; color: #2e7d32; border: 1px solid #c8e6c9; }
.alert-danger  { background: #ffebee; color: #c62828; border: 1px solid #ffcdd2; }
.alert-warning { background: #fff3e0; color: #e65100; border: 1px solid #ffe0b2; }
.alert-info    { background: #e3f2fd; color: #1565c0; border: 1px solid #bbdefb; }

/* ─── GALLERY GRID ──────────────────────────────────────────── */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 16px;
}

.gallery-item {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #f0f0f0;
  aspect-ratio: 4/3;
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.gallery-item-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  opacity: 0;
  transition: opacity var(--transition);
}
.gallery-item:hover .gallery-item-overlay { opacity: 1; }

.gallery-item-caption {
  padding: 8px 10px;
  font-size: .75rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--white);
  border-top: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ─── FINANCIAL ─────────────────────────────────────────────── */
.finance-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin-bottom: 24px;
}
.finance-card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px 22px;
  text-align: center;
  box-shadow: var(--shadow);
}
.finance-card small {
  display: block;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.finance-card strong {
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1;
}
.finance-card.entrada strong { color: #2e7d32; }
.finance-card.saida strong   { color: #c62828; }
.finance-card.saldo strong   { color: #1565c0; }

/* ─── STAR RATING ───────────────────────────────────────────── */
.stars { color: #f59e0b; letter-spacing: 2px; }

/* ─── PAGE SECTIONS ─────────────────────────────────────────── */
.page-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-actions h2 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* ─── DB INFO ────────────────────────────────────────────────── */
.db-table-list { list-style: none; }
.db-table-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: .88rem;
}
.db-table-list li:last-child { border-bottom: none; }
.db-table-list li strong { font-weight: 600; }
.db-table-list li span {
  font-size: .8rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 2px 10px;
  color: var(--text-secondary);
}

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

/* ─── CHART CONTAINER ────────────────────────────────────────── */
.chart-container {
  position: relative;
  height: 260px;
}

/* ─── FILTER BAR ────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 20px;
}
.filter-bar .form-group { margin-bottom: 0; }

/* ─── UPLOAD PREVIEW ─────────────────────────────────────────── */
.upload-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
}
.upload-preview img {
  width: 100px; height: 80px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}

/* ─── EMPTY STATE ────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}
.empty-state i { font-size: 2.5rem; margin-bottom: 12px; opacity: .4; display: block; }
.empty-state p { font-size: .9rem; }

/* ─── TOGGLE SWITCH ──────────────────────────────────────────── */
.toggle {
  position: relative;
  display: inline-block;
  width: 42px; height: 24px;
}
.toggle input { display: none; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: #ccc;
  border-radius: 100px;
  cursor: pointer;
  transition: background var(--transition);
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--transition);
  box-shadow: 0 1px 4px rgba(0,0,0,.25);
}
.toggle input:checked + .toggle-slider { background: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }

/* ─── LOGIN PAGE ─────────────────────────────────────────────── */
body.login-body {
  background: linear-gradient(135deg, #1A0A05 0%, #2c0f08 45%, #C62828 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  margin: 0;
}

.login-wrap {
  width: 100%;
  max-width: 420px;
  padding: 20px;
  animation: fadeUp .5s ease both;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}

.login-card {
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 24px 64px rgba(0,0,0,.35);
  overflow: hidden;
}

.login-card-top {
  background: linear-gradient(135deg, #1A0A05 0%, #C62828 100%);
  padding: 36px 32px 30px;
  text-align: center;
}

.login-logo-box {
  width: 72px; height: 72px;
  background: rgba(255,255,255,.15);
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
  backdrop-filter: blur(8px);
  border: 2px solid rgba(255,255,255,.25);
}
.login-logo-box i { font-size: 1.8rem; color: #fff; }

.login-card-top h1 {
  font-size: 1.4rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -.2px;
}
.login-card-top p {
  font-size: .8rem;
  color: rgba(255,255,255,.65);
  margin-top: 4px;
}

.login-card-body { padding: 32px; }

.login-field {
  margin-bottom: 18px;
}
.login-field label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 7px;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.login-input-wrap {
  position: relative;
}
.login-input-wrap i {
  position: absolute;
  left: 13px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: .9rem;
  pointer-events: none;
}
.login-input-wrap input {
  width: 100%;
  padding: 11px 14px 11px 40px;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  font-family: var(--font);
  font-size: .9rem;
  color: var(--text-primary);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.login-input-wrap input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(198,40,40,.12);
}

.btn-login {
  width: 100%;
  padding: 13px;
  background: linear-gradient(135deg, var(--accent), #e53935);
  color: #fff;
  border: none;
  border-radius: 9px;
  font-family: var(--font);
  font-size: .95rem;
  font-weight: 700;
  cursor: pointer;
  margin-top: 6px;
  letter-spacing: .3px;
  transition: box-shadow .2s, transform .15s;
}
.btn-login:hover {
  box-shadow: 0 6px 22px rgba(198,40,40,.4);
  transform: translateY(-1px);
}
.btn-login:active { transform: translateY(0); }

.login-error {
  background: #ffebee;
  border: 1px solid #ffcdd2;
  color: #c62828;
  border-radius: 8px;
  padding: 11px 14px;
  font-size: .85rem;
  font-weight: 500;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.login-footer-note {
  text-align: center;
  margin-top: 20px;
  font-size: .75rem;
  color: var(--text-muted);
}

/* ─── RESPONSIVE ─────────────────────────────────────────────── */
@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
  .finance-summary { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .admin-sidebar {
    transform: translateX(calc(-1 * var(--sidebar-w)));
    box-shadow: 4px 0 30px rgba(0,0,0,.35);
  }
  .admin-sidebar.open { transform: translateX(0); }

  .admin-main { margin-left: 0; }

  .sidebar-toggle { display: flex; }

  .admin-header h1 { font-size: 1rem; padding-left: 50px; }

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

  .admin-content { padding: 16px; }

  .admin-header { padding: 0 16px; }

  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .stat-card { padding: 16px; }
  .stat-info strong { font-size: 1.4rem; }
  .form-row { grid-template-columns: 1fr; }
}

/* ─── SCROLLBAR ─────────────────────────────────────────────── */
.admin-sidebar::-webkit-scrollbar { width: 4px; }
.admin-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 4px; }

/* ─── MISC ───────────────────────────────────────────────────── */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.w-100 { width: 100%; }
.img-thumb { width: 60px; height: 48px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }
