/* ===== ViaDesk Shared Styles ===== */
/* Loaded by every page — extracted from index.html + V2 additions */

/* Reset & Variables */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --primary: #1E5BAA; --primary-dark: #164785; --primary-light: #E8F0FE;
  --accent: #0EA5E9; --success: #16A34A; --success-light: #DCFCE7;
  --warning: #F59E0B; --warning-light: #FEF3C7; --error: #DC2626; --error-light: #FEE2E2;
  --text: #1E293B; --text-secondary: #64748B; --text-muted: #94A3B8;
  --bg: #F1F5F9; --white: #FFFFFF; --border: #E2E8F0;
  --sidebar-bg: #0F172A; --sidebar-text: #94A3B8; --sidebar-hover: #1E293B; --sidebar-active: #1E3A5F;
  --shadow: 0 1px 3px rgba(0,0,0,0.06); --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --radius: 8px; --radius-lg: 12px;
  --font: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}
body { font-family: var(--font); color: var(--text); background: var(--bg); line-height: 1.5; -webkit-font-smoothing: antialiased; }

/* Layout */
.layout { display: flex; min-height: 100vh; }
.main { margin-left: 240px; flex: 1; display: flex; flex-direction: column; min-height: 100vh; }

/* ===== Sidebar ===== */
.sidebar { width: 240px; background: var(--sidebar-bg); color: var(--sidebar-text); position: fixed; top: 0; left: 0; bottom: 0; z-index: 50; display: flex; flex-direction: column; }
.sidebar-header { padding: 20px 16px 16px; border-bottom: 1px solid rgba(255,255,255,0.06); }
.sidebar-logo { display: flex; align-items: center; gap: 10px; text-decoration: none; color: #fff; font-size: 18px; font-weight: 700; }
.sidebar-logo-icon { width: 32px; height: 32px; background: var(--primary); border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; color: #fff; }
.sidebar-version { font-size: 10px; color: var(--text-muted); margin-top: 6px; letter-spacing: 0.5px; text-transform: uppercase; }
.sidebar-nav { flex: 1; padding: 12px 8px; overflow-y: auto; }
.sidebar-nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--radius); color: var(--sidebar-text); text-decoration: none; font-size: 13.5px; font-weight: 500; transition: all 0.15s; margin-bottom: 1px; cursor: pointer; }
.sidebar-nav a:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar-nav a.active { background: var(--sidebar-active); color: #fff; }
.sidebar-nav .nav-icon { width: 18px; text-align: center; font-size: 15px; flex-shrink: 0; }
.sidebar-nav .badge { margin-left: auto; background: var(--error); color: #fff; font-size: 10px; font-weight: 700; padding: 1px 7px; border-radius: 10px; }
.sidebar-nav .nav-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.8px; color: #475569; padding: 16px 12px 6px; font-weight: 600; }
.sidebar-footer { padding: 12px; border-top: 1px solid rgba(255,255,255,0.06); }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--radius); cursor: pointer; }
.sidebar-user:hover { background: var(--sidebar-hover); }
.sidebar-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary); display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 12px; flex-shrink: 0; }
.sidebar-user-name { color: #fff; font-size: 13px; font-weight: 600; }
.sidebar-user-role { color: var(--sidebar-text); font-size: 11px; }
.sidebar-status { width: 8px; height: 8px; border-radius: 50%; background: var(--success); flex-shrink: 0; }

/* ===== Page Structure ===== */
.page-header { background: var(--white); border-bottom: 1px solid var(--border); padding: 20px 32px; display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.page-header h2 { font-size: 18px; font-weight: 700; }
.page-header-sub { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.page-content { padding: 24px 32px; flex: 1; overflow-y: auto; }

/* ===== Stats Cards ===== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--white); border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow); }
.stat-card-label { font-size: 12px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; }
.stat-card-value { font-size: 32px; font-weight: 700; margin-top: 4px; }
.stat-card-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ===== Tables ===== */
.admin-table-wrap { background: var(--white); border-radius: var(--radius-lg); box-shadow: var(--shadow); overflow: hidden; }
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th { text-align: left; padding: 12px 16px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-secondary); background: #F8FAFC; border-bottom: 1px solid var(--border); }
.admin-table td { padding: 12px 16px; font-size: 13px; border-bottom: 1px solid #F1F5F9; vertical-align: top; }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: #FAFBFC; }
.admin-table .actions { display: flex; gap: 6px; }

/* ===== Buttons ===== */
.btn { padding: 7px 14px; border-radius: 6px; font-size: 12px; font-weight: 600; cursor: pointer; border: 1px solid var(--border); background: var(--white); font-family: var(--font); transition: all 0.15s; display: inline-flex; align-items: center; gap: 5px; }
.btn:hover { background: var(--bg); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { color: var(--error); border-color: var(--error-light); }
.btn-danger:hover { background: var(--error-light); }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { background: #15803d; }
.btn-warning { background: var(--warning); color: #fff; border-color: var(--warning); }
.btn-warning:hover { background: #d97706; }
.btn-sm { padding: 4px 10px; font-size: 11px; }
.btn-lg { padding: 10px 20px; font-size: 14px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* ===== Badges ===== */

/* Role badges */
.role-badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.role-badge.admin { background: #EDE9FE; color: #7C3AED; }
.role-badge.manager { background: #FEF3C7; color: #B45309; }
.role-badge.support { background: #DBEAFE; color: #2563EB; }
.role-badge.hotel_support { background: #DCFCE7; color: #16A34A; }

/* Status dot */
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.status-dot.online { background: var(--success); }
.status-dot.away { background: var(--warning); }
.status-dot.offline { background: var(--text-muted); }

/* Stage badges — updated: step2 → hotel_form */
.stage-badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.stage-badge.purchase { background: #DBEAFE; color: #2563EB; }
.stage-badge.hotel_form { background: #FEF3C7; color: #B45309; }
.stage-badge.step2 { background: #FEF3C7; color: #B45309; } /* legacy compat */
.stage-badge.reservation { background: #E0E7FF; color: #4338CA; }
.stage-badge.confirmed { background: #DCFCE7; color: #16A34A; }
.stage-badge.post_stay { background: #F3E8FF; color: #7C3AED; }
.stage-badge.nq { background: #FEE2E2; color: #DC2626; }

/* Category tag */
.cat-tag { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; background: #F1F5F9; color: var(--text-secondary); }

/* Sentiment badges (V2) */
.sentiment-badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.sentiment-badge.positive { background: #DCFCE7; color: #16A34A; }
.sentiment-badge.neutral { background: #F1F5F9; color: #64748B; }
.sentiment-badge.negative { background: #FEF3C7; color: #B45309; }
.sentiment-badge.angry { background: #FEE2E2; color: #DC2626; }

/* Urgency badges (V2) */
.urgency-badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 700; }
.urgency-badge.critical { background: #DC2626; color: #fff; }
.urgency-badge.high { background: #F59E0B; color: #fff; }
.urgency-badge.medium { background: #FEF3C7; color: #B45309; }
.urgency-badge.normal { background: #F1F5F9; color: #64748B; }

/* SLA breach indicator */
.sla-breach { background: var(--error); color: #fff; padding: 2px 8px; border-radius: 4px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; animation: sla-pulse 2s infinite; }
@keyframes sla-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.7; } }

/* Source/channel icons */
.source-badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; background: #F1F5F9; color: var(--text-secondary); }

/* ===== Modals ===== */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 100; align-items: center; justify-content: center; }
.modal-overlay.active { display: flex; }
.modal { background: var(--white); border-radius: var(--radius-lg); width: 100%; max-width: 560px; max-height: 85vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.15); }
.modal-wide { max-width: 720px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 16px; }
.modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--text-muted); padding: 4px; }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* ===== Forms ===== */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 13px; font-family: var(--font); outline: none; transition: border-color .15s; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--primary); }
.form-group textarea { resize: vertical; min-height: 100px; }
.form-group .hint { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* Toggles (V2 — for is_public etc.) */
.toggle-wrap { display: flex; align-items: center; gap: 8px; }
.toggle { position: relative; width: 36px; height: 20px; background: var(--border); border-radius: 10px; cursor: pointer; transition: background 0.2s; }
.toggle.on { background: var(--success); }
.toggle::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; background: #fff; border-radius: 50%; transition: transform 0.2s; }
.toggle.on::after { transform: translateX(16px); }
.toggle-label { font-size: 13px; font-weight: 500; }

/* ===== Toast ===== */
.toast { position: fixed; bottom: 20px; right: 20px; background: var(--text); color: #fff; padding: 12px 20px; border-radius: var(--radius); font-size: 13px; font-weight: 500; z-index: 200; transform: translateY(80px); opacity: 0; transition: all 0.3s; }
.toast.show { transform: translateY(0); opacity: 1; }

/* ===== Empty States ===== */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state-text { font-size: 15px; font-weight: 600; color: var(--text-secondary); }
.empty-state-sub { font-size: 13px; margin-top: 4px; }

/* ===== Table Toolbar / Search ===== */
.table-toolbar { display: flex; align-items: center; justify-content: space-between; padding: 16px; border-bottom: 1px solid var(--border); gap: 12px; flex-wrap: wrap; }
.table-search { padding: 7px 12px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 13px; font-family: var(--font); width: 260px; outline: none; }
.table-search:focus { border-color: var(--primary); }

/* ===== Department Tabs (V2) ===== */
.dept-tabs { display: flex; gap: 2px; background: #F1F5F9; border-radius: var(--radius); padding: 3px; }
.dept-tab { padding: 6px 14px; border-radius: 6px; font-size: 12px; font-weight: 600; cursor: pointer; color: var(--text-secondary); background: transparent; border: none; font-family: var(--font); transition: all 0.15s; }
.dept-tab:hover { color: var(--text); }
.dept-tab.active { background: var(--white); color: var(--text); box-shadow: var(--shadow); }

/* ===== KB Content Preview ===== */
.kb-content-preview { max-height: 80px; overflow: hidden; color: var(--text-secondary); font-size: 12px; line-height: 1.4; }

/* ===== Inbox Placeholder ===== */
.inbox-placeholder { display: flex; align-items: center; justify-content: center; flex: 1; color: var(--text-muted); font-size: 14px; }

/* ===== Utility ===== */
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.gap-8 { gap: 8px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
