/* ===================================================
   LIA SaaS — app.css
   Variables tenant injectées inline via :root { --accent }
   =================================================== */

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

:root {
  --accent: #6366f1;
  --accent-dark: color-mix(in srgb, var(--accent) 80%, black);
  --accent-light: color-mix(in srgb, var(--accent) 12%, white);
  --bg: #f8f9fb;
  --surface: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --text-muted: #6b7280;
  --sidebar-w: 220px;
  --radius: 8px;
  --shadow: 0 1px 4px rgba(0,0,0,.08);
}

body { font-family: system-ui, -apple-system, sans-serif; font-size: 14px;
       background: var(--bg); color: var(--text); min-height: 100vh; }

/* ---- 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; flex-shrink: 0; position: sticky; top: 0; height: 100vh;
}
.sidebar-logo {
  padding: 20px 16px 12px; font-size: 20px; font-weight: 700;
  color: var(--accent); letter-spacing: -.5px; border-bottom: 1px solid var(--border);
}
.sidebar-nav { flex: 1; padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--radius);
  text-decoration: none; color: var(--text-muted); font-size: 13.5px; transition: all .15s;
}
.nav-link:hover { background: var(--accent-light); color: var(--accent); }
.nav-link.active { background: var(--accent-light); color: var(--accent); font-weight: 600; }

.sidebar-footer { padding: 12px 8px; border-top: 1px solid var(--border); }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 8px; margin-bottom: 8px; }
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--accent);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.user-name { font-weight: 600; font-size: 13px; }
.user-role { font-size: 11px; color: var(--text-muted); }
.btn-logout {
  display: block; text-align: center; padding: 7px; border-radius: var(--radius);
  background: var(--bg); color: var(--text-muted); text-decoration: none; font-size: 13px;
}
.btn-logout:hover { background: #fee2e2; color: #dc2626; }

.main-content { flex: 1; padding: 28px 32px; max-width: 1100px; }

/* ---- PAGE HEADER ---- */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.page-header h1 { font-size: 22px; font-weight: 700; }

/* ---- CARDS GRID ---- */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.card-title { font-weight: 600; font-size: 15px; margin-bottom: 6px; }
.card-meta { font-size: 12px; color: var(--text-muted); margin-bottom: 12px; }
.card-actions { display: flex; gap: 8px; }

/* ---- STAT CARDS ---- */
.stats-row { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 28px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 24px; flex: 1; min-width: 160px; box-shadow: var(--shadow);
}
.stat-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--accent); margin-top: 4px; }

/* ---- TABLE ---- */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th { background: var(--bg); padding: 10px 14px; text-align: left; font-size: 12px;
     text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); border-bottom: 1px solid var(--border); }
td { padding: 11px 14px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--accent-light); }

/* ---- FORMS ---- */
.form-group { margin-bottom: 16px; }
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; }
input, textarea, select {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 14px; font-family: inherit; background: var(--surface); transition: border .15s;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }
textarea { resize: vertical; min-height: 90px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ---- BUTTONS ---- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px;
  border-radius: var(--radius); font-size: 13.5px; font-weight: 600; cursor: pointer;
  border: none; text-decoration: none; transition: all .15s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: #fee2e2; color: #dc2626; }
.btn-danger:hover { background: #fca5a5; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ---- BADGE ---- */
.badge { display: inline-flex; padding: 3px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-green  { background: #d1fae5; color: #065f46; }
.badge-blue   { background: #dbeafe; color: #1e40af; }
.badge-orange { background: #ffedd5; color: #9a3412; }
.badge-gray   { background: #f3f4f6; color: #6b7280; }
.badge-purple { background: var(--accent-light); color: var(--accent); }

/* ---- FLASH ---- */
.flash { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; font-size: 13.5px; }
.flash-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.flash-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.flash-info    { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

/* ---- EMPTY STATE ---- */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-sub { font-size: 13px; margin-top: 6px; }

/* ---- SKELETON ---- */
.skeleton {
  height: 60px; background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%; animation: shimmer 1.4s infinite;
  border-radius: var(--radius); margin-bottom: 8px;
}
@keyframes shimmer { 0%{background-position:200% 0} 100%{background-position:-200% 0} }

/* ---- STUDIO IA ---- */
.studio-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.panel-title { font-weight: 700; margin-bottom: 16px; font-size: 15px; }
.generation-item { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; }
.generation-prompt { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.generation-output { font-size: 13.5px; line-height: 1.6; white-space: pre-wrap; }
.channel-tag { display: inline-flex; padding: 3px 8px; background: var(--accent-light); color: var(--accent); border-radius: 20px; font-size: 11px; font-weight: 600; margin-bottom: 8px; }

/* ---- LOADING SPINNER ---- */
.spinner { display: inline-block; width: 18px; height: 18px; border: 2px solid var(--border);
           border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- LOGIN PAGE ---- */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-box { background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
             padding: 40px; width: 100%; max-width: 400px; box-shadow: var(--shadow); }
.login-logo { font-size: 28px; font-weight: 800; color: var(--accent); margin-bottom: 8px; }
.login-sub { color: var(--text-muted); font-size: 14px; margin-bottom: 28px; }

/* ---- CREDITS BAR ---- */
.credits-bar { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
               padding: 12px 16px; display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.credits-track { flex: 1; height: 6px; background: var(--border); border-radius: 3px; }
.credits-fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width .3s; }
.credits-label { font-size: 12px; color: var(--text-muted); min-width: 120px; text-align: right; }

/* ---- CALENDAR ---- */
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-day { background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
           padding: 8px; min-height: 80px; }
.cal-day-num { font-size: 12px; font-weight: 700; color: var(--text-muted); margin-bottom: 4px; }
.cal-event { font-size: 11px; background: var(--accent-light); color: var(--accent);
             border-radius: 4px; padding: 2px 5px; margin-bottom: 2px; cursor: pointer;
             overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- SECTION DIVIDER ---- */
.section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
                 color: var(--text-muted); margin: 24px 0 12px; }

@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { padding: 16px; }
  .form-row { grid-template-columns: 1fr; }
  .studio-grid { grid-template-columns: 1fr; }
}
