/* ============================================
   BabRawda Sales Operations Cockpit
   Design System & Complete Stylesheet
   Brand: Emerald #014931, Dark #033B28, Gold #BB953B
   ============================================ */

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

:root {
    --primary: #014931;
    --primary-dark: #033B28;
    --primary-light: #026d49;
    --accent: #BB953B;
    --accent-light: #d4ad5a;
    --bg: #f4f6f9;
    --surface: #ffffff;
    --surface-hover: #f8fafc;
    --text: #1a1f26;
    --text-muted: #6b7280;
    --text-light: #9ca3af;
    --border: #e5e7eb;
    --border-light: #f3f4f6;
    --danger: #ef4444;
    --danger-bg: #fef2f2;
    --success: #10b981;
    --success-bg: #ecfdf5;
    --warning: #f59e0b;
    --warning-bg: #fffbeb;
    --info: #3b82f6;
    --info-bg: #eff6ff;
    --touch: 48px;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
    --transition: 0.2s ease;
}

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

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
    font-family: 'Inter', 'IBM Plex Sans Arabic', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

/* ---- Layout ---- */
.app-container { max-width: 1440px; margin: 0 auto; min-height: 100vh; }

.page-header {
    background: var(--primary);
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}
.page-header .brand { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.page-header .brand span { color: var(--accent); }
.page-header .user-info { font-size: 13px; opacity: 0.85; }

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: var(--touch);
    padding: 0 24px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    border: none;
    font-family: inherit;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-light); }
.btn-accent { background: var(--accent); color: white; }
.btn-accent:hover { background: var(--accent-light); }
.btn-outline { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: var(--danger); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--border-light); }
.btn-full { width: 100%; }
.btn-lg { min-height: 56px; font-size: 18px; padding: 0 32px; border-radius: var(--radius); }
.btn-xl { min-height: 72px; font-size: 22px; font-weight: 700; padding: 0 40px; border-radius: 16px; letter-spacing: -0.01em; }
.btn-sm { min-height: 36px; font-size: 13px; padding: 0 16px; }
.btn-icon { width: var(--touch); padding: 0; }

/* ---- Cards ---- */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
}
.card-body { padding: 20px; }

/* ---- Forms ---- */
.form-group { margin-bottom: 20px; }
.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 14px;
    color: var(--text);
}
.form-input {
    width: 100%;
    min-height: var(--touch);
    padding: 0 16px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-family: inherit;
    background: var(--surface);
    transition: border-color var(--transition), box-shadow var(--transition);
}
.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(1,73,49,0.12);
}
.form-input::placeholder { color: var(--text-light); }

textarea.form-input { padding: 12px 16px; min-height: 100px; resize: vertical; }

/* ---- Flash Messages ---- */
.flash-messages {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    width: 90%;
    max-width: 420px;
}
.flash {
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 14px;
    text-align: center;
    animation: flashIn 0.3s ease;
}
@keyframes flashIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
.flash-error { background: var(--danger-bg); color: #991b1b; border: 1px solid #fca5a5; }
.flash-success { background: var(--success-bg); color: #065f46; border: 1px solid #6ee7b7; }

/* ---- Login ---- */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
}
.login-box {
    background: var(--surface);
    padding: 48px 40px;
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
    text-align: center;
}
.login-box .brand-logo {
    font-size: 36px;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 4px;
    letter-spacing: -0.03em;
}
.login-box .brand-sub {
    color: var(--accent);
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 36px;
}
.login-box .form-group { text-align: left; }

/* ---- Stat Cards ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    padding: 0 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
}
.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
    line-height: 1.2;
}
.stat-card .stat-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.stat-card.hot .stat-value { color: var(--danger); }
.stat-card.accent .stat-value { color: var(--accent); }

/* ---- Section ---- */
.section { padding: 20px 16px; }
.section-title {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 700;
    letter-spacing: 0.08em;
    margin-bottom: 12px;
}

/* ---- Company List ---- */
.company-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    cursor: pointer;
    transition: border-color var(--transition);
}
.company-item:hover { border-color: var(--primary); }
.company-item .company-name { font-weight: 600; font-size: 15px; }
.company-item .company-meta { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.company-item .company-actions { display: flex; gap: 8px; }

.stage-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.stage-new { background: var(--info-bg); color: #1d4ed8; }
.stage-connected { background: #fef3c7; color: #92400e; }
.stage-qualified { background: var(--success-bg); color: #065f46; }
.stage-interested { background: #ede9fe; color: #5b21b6; }
.stage-won { background: var(--success); color: white; }
.stage-lost { background: var(--danger-bg); color: #991b1b; }

/* ---- COCKPIT ---- */
.cockpit { min-height: 100vh; background: var(--bg); padding-bottom: 100px; }

.cockpit-header {
    position: sticky;
    top: 0;
    background: var(--primary-dark);
    color: white;
    padding: 16px 20px;
    z-index: 50;
}
.cockpit-header .ch-company { font-size: 20px; font-weight: 700; }
.cockpit-header .ch-contact { font-size: 14px; opacity: 0.85; margin-top: 2px; }
.cockpit-header .ch-meta { font-size: 13px; opacity: 0.7; margin-top: 4px; }
.cockpit-actions {
    display: flex;
    gap: 10px;
    margin-top: 12px;
}
.cockpit-actions .btn { flex: 1; font-size: 15px; min-height: 44px; }
.btn-call { background: var(--accent); color: white; font-weight: 700; }
.btn-whatsapp { background: #25d366; color: white; }
.btn-email-action { background: var(--info); color: white; }

/* Progress bar */
.step-progress {
    display: flex;
    gap: 4px;
    padding: 12px 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.step-dot {
    flex: 1;
    height: 4px;
    border-radius: 2px;
    background: var(--border);
    transition: background var(--transition);
}
.step-dot.active { background: var(--primary); }
.step-dot.done { background: var(--accent); }
.step-label {
    text-align: center;
    padding: 8px 20px 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
}

/* Script card */
.script-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin: 16px;
    font-size: 18px;
    line-height: 1.7;
    direction: rtl;
    text-align: right;
    font-family: 'IBM Plex Sans Arabic', 'Inter', sans-serif;
}
.script-card.ltr { direction: ltr; text-align: left; font-family: 'Inter', sans-serif; }
.script-card .script-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
    direction: ltr;
    text-align: left;
}

/* Quick answer buttons */
.quick-answers {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 0 16px;
    margin-bottom: 16px;
}
.quick-answer {
    min-height: 56px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    font-family: 'IBM Plex Sans Arabic', 'Inter', sans-serif;
    transition: all var(--transition);
    padding: 12px;
}
.quick-answer:hover { border-color: var(--primary); background: rgba(1,73,49,0.03); }
.quick-answer.selected { border-color: var(--primary); background: rgba(1,73,49,0.08); color: var(--primary); }
.quick-answer.full-width { grid-column: 1 / -1; }

/* Chips */
.chip-group { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 16px; margin-bottom: 16px; }
.chip {
    display: inline-flex;
    align-items: center;
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: 1.5px solid var(--border);
    background: var(--surface);
    transition: all var(--transition);
    font-family: 'IBM Plex Sans Arabic', 'Inter', sans-serif;
}
.chip:hover { border-color: var(--primary); }
.chip.selected { background: var(--primary); color: white; border-color: var(--primary); }

/* Objection cards */
.objection-search-box {
    margin: 0 16px 16px;
    position: relative;
}
.objection-search-box input {
    width: 100%;
    min-height: 52px;
    padding: 0 16px 0 44px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 16px;
    font-family: 'IBM Plex Sans Arabic', 'Inter', sans-serif;
    background: var(--surface);
}
.objection-search-box input:focus { outline: none; border-color: var(--primary); }
.objection-search-box .search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 18px;
    color: var(--text-muted);
}

.objection-card {
    background: var(--warning-bg);
    border: 1px solid #fcd34d;
    border-radius: var(--radius);
    padding: 16px;
    margin: 0 16px 12px;
}
.objection-card .obj-question {
    font-weight: 700;
    font-size: 15px;
    margin-bottom: 8px;
    font-family: 'IBM Plex Sans Arabic', 'Inter', sans-serif;
}
.objection-card .obj-answer {
    font-size: 15px;
    line-height: 1.6;
    font-family: 'IBM Plex Sans Arabic', 'Inter', sans-serif;
}
.objection-card .obj-warning {
    margin-top: 10px;
    padding: 8px 12px;
    background: var(--danger-bg);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: #991b1b;
    font-weight: 500;
}
.objection-card .obj-actions { display: flex; gap: 8px; margin-top: 12px; }

/* Notes */
.notes-area {
    margin: 0 16px 16px;
}
.notes-area textarea {
    width: 100%;
    min-height: 80px;
    padding: 12px 16px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-family: 'IBM Plex Sans Arabic', 'Inter', sans-serif;
    resize: vertical;
}
.notes-area textarea:focus { outline: none; border-color: var(--primary); }

/* Note chips */
.note-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.note-chip {
    padding: 6px 12px;
    background: var(--border-light);
    border-radius: 16px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    font-family: 'IBM Plex Sans Arabic', 'Inter', sans-serif;
    transition: background var(--transition);
}
.note-chip:hover { background: var(--border); }

/* Outcome grid */
.outcome-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 0 16px 16px;
}
.outcome-btn {
    min-height: 52px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    font-family: inherit;
    transition: all var(--transition);
    padding: 10px;
}
.outcome-btn:hover { border-color: var(--primary); }
.outcome-btn.selected { background: var(--primary); color: white; border-color: var(--primary); }
.outcome-btn.positive { border-color: var(--success); color: #065f46; }
.outcome-btn.negative { border-color: var(--danger); color: #991b1b; }

/* Sticky Footer */
.cockpit-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 12px 16px;
    display: flex;
    gap: 12px;
    z-index: 50;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}
.cockpit-footer .btn { flex: 1; }

/* Checklist */
.checklist { padding: 0 16px; margin-bottom: 16px; }
.checklist-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 14px;
}
.checklist-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--primary);
}

/* Follow-up quick picks */
.followup-picks {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 0 16px;
    margin-bottom: 16px;
}
.followup-pick {
    min-height: 48px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    font-family: inherit;
    transition: all var(--transition);
}
.followup-pick:hover { border-color: var(--primary); }
.followup-pick.selected { background: var(--primary); color: white; border-color: var(--primary); }

/* Language toggle */
.lang-toggle {
    display: inline-flex;
    background: rgba(255,255,255,0.15);
    border-radius: 6px;
    overflow: hidden;
}
.lang-toggle button {
    padding: 6px 14px;
    border: none;
    background: transparent;
    color: rgba(255,255,255,0.7);
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: all var(--transition);
}
.lang-toggle button.active {
    background: rgba(255,255,255,0.25);
    color: white;
}

/* ---- Admin Dashboard ---- */
.admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    padding: 0 20px;
    margin-bottom: 24px;
}

.employee-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}
.employee-card .emp-name { font-weight: 700; font-size: 16px; margin-bottom: 12px; }
.employee-card .emp-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.employee-card .emp-stat { font-size: 13px; color: var(--text-muted); }
.employee-card .emp-stat strong { color: var(--text); font-size: 18px; display: block; }

/* Pipeline bars */
.funnel { padding: 0 20px; margin-bottom: 24px; }
.funnel-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}
.funnel-label { width: 120px; font-size: 13px; font-weight: 500; color: var(--text-muted); text-align: right; }
.funnel-bar-bg { flex: 1; height: 28px; background: var(--border-light); border-radius: 4px; overflow: hidden; }
.funnel-bar { height: 100%; background: var(--primary); border-radius: 4px; transition: width 0.5s ease; display: flex; align-items: center; padding-left: 8px; font-size: 12px; font-weight: 600; color: white; min-width: 30px; }

/* ---- Bottom Nav (Mobile) ---- */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    display: flex;
    z-index: 100;
    padding: 4px 0;
}
.bottom-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 4px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    transition: color var(--transition);
}
.bottom-nav a.active { color: var(--primary); }
.bottom-nav a .nav-icon { font-size: 22px; }

/* Hide bottom nav in cockpit */
.cockpit ~ .bottom-nav { display: none; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .admin-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .login-box { padding: 32px 24px; }
}
@media (min-width: 769px) {
    body { padding-bottom: 0; }
    .bottom-nav { display: none; }
}

/* ---- Utility ---- */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.p-16 { padding: 16px; }
.p-20 { padding: 20px; }
.hidden { display: none !important; }
