/* ===== SHARED STYLES — Century 21 Faro App ===== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700;800&display=swap');

:root {
  --gold: #C5A255;
  --gold-light: #D4B76A;
  --gold-dark: #A68A3E;
  --black: #0D0D0D;
  --dark: #1A1A2E;
  --dark-surface: #16213E;
  --dark-card: #1e2a4a;
  --white: #FFFFFF;
  --gray-100: #F5F5F5;
  --gray-200: #E0E0E0;
  --gray-300: #B0B0B0;
  --gray-400: #7A7A7A;
  --green: #2ECC71;
  --red: #E74C3C;
  --blue: #3498DB;
  --font-heading: 'Outfit', sans-serif;
  --font-body: 'Inter', sans-serif;
  --sidebar-width: 260px;
  --transition: 0.3s ease;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 15px; }
body { font-family: var(--font-body); background: var(--black); color: var(--white); line-height: 1.6; }
a { text-decoration: none; color: inherit; }
ul { list-style: none; }
img { max-width: 100%; display: block; }
input, textarea, select, button { font-family: inherit; font-size: inherit; }

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

/* SIDEBAR */
.sidebar {
  width: var(--sidebar-width);
  background: var(--dark);
  border-right: 1px solid rgba(255,255,255,0.06);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
}

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

.sidebar-brand .logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-heading); font-weight: 800; font-size: 0.75rem; color: var(--black);
}

.sidebar-brand .brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.sidebar-brand .brand-name { font-family: var(--font-heading); font-weight: 700; font-size: 1.05rem; }
.sidebar-brand .brand-sub { font-size: 0.6rem; letter-spacing: 2px; text-transform: uppercase; color: var(--gold); }

.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }

.sidebar-nav a, .sidebar-nav button {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; border-radius: 10px;
  font-size: 0.88rem; font-weight: 500; color: var(--gray-300);
  transition: all var(--transition); cursor: pointer;
  width: 100%; border: none; background: none; text-align: left;
}

.sidebar-nav a:hover, .sidebar-nav button:hover { background: rgba(255,255,255,0.05); color: var(--white); }
.sidebar-nav a.active, .sidebar-nav button.active { background: rgba(197,162,85,0.15); color: var(--gold); }
.sidebar-nav .nav-icon { font-size: 1.15rem; width: 24px; text-align: center; }

.sidebar-section-label {
  font-size: 0.65rem; font-weight: 600; letter-spacing: 2px; text-transform: uppercase;
  color: var(--gray-400); padding: 20px 14px 8px; margin-top: 4px;
}

.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 10px;
  background: rgba(255,255,255,0.03);
}

.sidebar-user img {
  width: 34px; height: 34px; border-radius: 8px; object-fit: cover;
  border: 1.5px solid rgba(197,162,85,0.3);
}

.sidebar-user .user-name { font-size: 0.85rem; font-weight: 600; }
.sidebar-user .user-role { font-size: 0.65rem; color: var(--gold); text-transform: uppercase; letter-spacing: 1px; }

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

.topbar {
  padding: 20px 32px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(13,13,13,0.8);
  backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 50;
}

.topbar h1 {
  font-family: var(--font-heading); font-size: 1.5rem; font-weight: 700;
}

.topbar-actions { display: flex; align-items: center; gap: 12px; }

.content-area {
  flex: 1;
  padding: 32px;
}

/* ===== COMPONENTS ===== */

/* Cards */
.card {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 14px;
  padding: 24px;
  transition: all var(--transition);
}
.card:hover { border-color: rgba(197,162,85,0.15); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 20px; border-radius: 10px;
  font-weight: 600; font-size: 0.85rem;
  cursor: pointer; border: none;
  transition: all var(--transition);
}

.btn-gold {
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  color: var(--black);
  box-shadow: 0 4px 15px rgba(197,162,85,0.3);
}
.btn-gold:hover { transform: translateY(-2px); box-shadow: 0 6px 25px rgba(197,162,85,0.4); }

.btn-outline-gold {
  background: transparent; color: var(--gold);
  border: 1.5px solid rgba(197,162,85,0.3);
}
.btn-outline-gold:hover { background: rgba(197,162,85,0.1); }

.btn-danger {
  background: rgba(231,76,60,0.15); color: var(--red);
  border: 1px solid rgba(231,76,60,0.2);
}
.btn-danger:hover { background: rgba(231,76,60,0.25); }

.btn-outline-danger {
  background: rgba(13,13,13,0.35);
  color: var(--red);
  border: 1px solid rgba(231,76,60,0.28);
}
.btn-outline-danger:hover {
  background: rgba(231,76,60,0.16);
  border-color: rgba(231,76,60,0.5);
  transform: translateY(-1px);
}

.sidebar-logout {
  width: 100%;
  justify-content: center;
  padding: 10px 14px;
  margin-top: 10px;
}

.btn-sm { padding: 7px 14px; font-size: 0.78rem; }

.btn-green {
  background: rgba(46,204,113,0.15); color: var(--green);
  border: 1px solid rgba(46,204,113,0.2);
}
.btn-green:hover { background: rgba(46,204,113,0.25); }

/* Forms */
.form-group { margin-bottom: 18px; }
.form-group label {
  display: block; font-size: 0.78rem; font-weight: 600;
  color: var(--gray-300); margin-bottom: 6px;
  text-transform: uppercase; letter-spacing: 1px;
}

.form-control {
  width: 100%; padding: 11px 16px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px; color: var(--white);
  transition: border-color var(--transition);
  outline: none;
}
.form-control:focus { border-color: var(--gold); }
.form-control::placeholder { color: var(--gray-400); }

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

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23B0B0B0'%3E%3Cpath d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

/* Dropdown list (native) colors */
select.form-control option,
select.form-control optgroup {
  background: var(--dark);
  color: var(--white);
}

/* Grid */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }

/* Stat cards */
.stat-card-mini {
  padding: 20px;
  display: flex; align-items: center; gap: 16px;
}
.stat-card-mini .stat-icon-wrap {
  width: 48px; height: 48px;
  background: rgba(197,162,85,0.12); border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
}
.stat-card-mini .stat-value {
  font-family: var(--font-heading); font-size: 1.8rem; font-weight: 700; color: var(--gold); line-height: 1;
}
.stat-card-mini .stat-label-mini { font-size: 0.78rem; color: var(--gray-400); margin-top: 2px; }

/* Tables */
.table-wrap { overflow-x: auto; border-radius: 12px; border: 1px solid rgba(255,255,255,0.06); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 18px; text-align: left; font-size: 0.88rem; }
th {
  background: rgba(255,255,255,0.04); color: var(--gray-300);
  font-weight: 600; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 1px;
}
td { border-top: 1px solid rgba(255,255,255,0.04); }
tr:hover td { background: rgba(255,255,255,0.02); }

/* Badges */
.badge {
  display: inline-block; padding: 4px 10px; border-radius: 6px;
  font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
}
.badge-gold { background: rgba(197,162,85,0.15); color: var(--gold); }
.badge-green { background: rgba(46,204,113,0.15); color: var(--green); }
.badge-red { background: rgba(231,76,60,0.15); color: var(--red); }
.badge-blue { background: rgba(52,152,219,0.15); color: var(--blue); }

/* Modal */
.modal-overlay {
  display: none; position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(4px);
  align-items: center; justify-content: center;
}
.modal-overlay.active { display: flex; }

.modal {
  background: var(--dark); border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px; padding: 32px; width: 90%; max-width: 560px;
  max-height: 85vh; overflow-y: auto;
  animation: modalIn 0.3s ease;
}
@keyframes modalIn { from { opacity: 0; transform: scale(0.95) translateY(10px); } to { opacity: 1; transform: none; } }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}
.modal-header h2 { font-family: var(--font-heading); font-size: 1.3rem; font-weight: 700; }
.modal-close {
  width: 32px; height: 32px; border-radius: 8px; border: none;
  background: rgba(255,255,255,0.05); color: var(--gray-300);
  cursor: pointer; font-size: 1.1rem; display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: rgba(255,255,255,0.1); }

.modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 24px; }

/* Toast */
.toast-container {
  position: fixed; top: 24px; right: 24px; z-index: 2000;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 14px 20px; border-radius: 10px;
  font-size: 0.85rem; font-weight: 500;
  animation: toastIn 0.3s ease;
  display: flex; align-items: center; gap: 8px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.3);
}
.toast-success { background: #1a3a2a; color: var(--green); border: 1px solid rgba(46,204,113,0.2); }
.toast-error { background: #3a1a1a; color: var(--red); border: 1px solid rgba(231,76,60,0.2); }
@keyframes toastIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: none; } }

/* Empty state */
.empty-state {
  text-align: center; padding: 60px 20px; color: var(--gray-400);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 16px; }
.empty-state p { font-size: 0.95rem; }

/* Mobile sidebar toggle */
.sidebar-toggle {
  display: none; border: none; background: none;
  color: var(--white); font-size: 1.3rem; cursor: pointer; padding: 8px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .sidebar-toggle { display: block; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .content-area { padding: 20px; }
  .topbar { padding: 16px 20px; }
}

/* ===== AI-gated UI ===== */
/* When OPENAI_API_KEY is not set, /api/ai/status returns {enabled:false}
   and office.js adds class "ai-disabled" to <html> — hide every AI button. */
.ai-disabled .ai-only { display: none !important; }
