/* ══════════════════════════════════════════════════════════════════
   LAYOUT SHELL — header + labelled sidebar + breadcrumb + content
   ══════════════════════════════════════════════════════════════════ */

:root {
    --hdr-h: 60px;
    --side-w: 248px;
    --side-bg: #0f172a;
    --side-bg-2: #111c33;
    --side-text: #cbd5e1;
    --side-text-dim: #94a3b8;
    --side-hover: rgba(255,255,255,.05);
    --side-border: rgba(255,255,255,.06);
    --accent: #3b82f6;
    --accent-soft: rgba(59,130,246,.18);
}

/* ── Fixed top header ───────────────────────────────────────────── */
.app-header {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--hdr-h);
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(15,23,42,.04);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 20px;
    z-index: 1050;
}
.hdr-left { display: flex; align-items: center; gap: 10px; min-width: calc(var(--side-w) - 20px); }
.sidebar-toggle {
    background: transparent; border: none;
    width: 36px; height: 36px;
    border-radius: 8px;
    color: #475569; font-size: 16px;
    display: inline-flex; align-items: center; justify-content: center;
}
.sidebar-toggle:hover { background: #f1f5f9; }
/* ── George Telegraph brand badge ───────────────────────────────── */
.gt-brand { display: inline-flex; align-items: center; text-decoration: none !important; }
.gt-brand-mark {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    background: #1a237e;                /* George Telegraph dark blue */
    border-radius: 6px;
    padding: 5px 14px 4px;
    line-height: 1;
    box-shadow: 0 2px 6px rgba(26,35,126,.25);
}
.gt-brand-name {
    font-family: 'Inter', sans-serif;
    font-weight: 800;
    font-size: 14px;
    color: #ffd400;                      /* signature yellow */
    letter-spacing: .5px;
}
.gt-brand-since {
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 9px;
    color: #ffffff;
    letter-spacing: 1.5px;
    margin-top: 2px;
}
.gt-brand:hover .gt-brand-mark { box-shadow: 0 3px 10px rgba(26,35,126,.35); }

/* Larger version on login page */
.gt-login-brand {
    display: inline-flex; flex-direction: column; align-items: center;
    background: #1a237e;
    border-radius: 8px;
    padding: 12px 24px 10px;
    margin: 0 auto 18px;
    line-height: 1;
    box-shadow: 0 6px 16px rgba(26,35,126,.25);
}
.gt-login-brand .gt-brand-name { font-size: 22px; }
.gt-login-brand .gt-brand-since { font-size: 11px; margin-top: 4px; }
.login-card { text-align: center; }
.login-card form { text-align: left; }

/* Legacy logo classes kept for any view that still references them */
.app-logo-icon {
    width: 32px; height: 32px;
    background: #1a237e;
    border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    color: #ffd400; font-size: 14px; flex-shrink: 0;
}
.app-logo-text { font-weight: 700; font-size: 15px; color: #0f172a; letter-spacing: -.3px; }

/* Header search */
.hdr-search {
    flex: 1; max-width: 460px;
    position: relative;
    height: 38px;
}
.hdr-search i.fa-search {
    position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
    color: #94a3b8; font-size: 13px;
    pointer-events: none;
}
.hdr-search input {
    width: 100%; height: 100%;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    border-radius: 10px;
    padding: 0 44px 0 38px;
    font-size: 13.5px;
    color: #1e293b;
    transition: border-color .15s, background .15s, box-shadow .15s;
}
.hdr-search input:focus {
    outline: none;
    border-color: var(--accent);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}
.hdr-search-kbd {
    position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
    background: #fff; border: 1px solid #e2e8f0;
    border-radius: 5px;
    padding: 1px 7px;
    font-size: 11px; font-weight: 600; color: #94a3b8;
    font-family: 'Inter', sans-serif;
}

/* Header user */
.hdr-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.hdr-user-btn {
    display: flex; align-items: center; gap: 10px;
    border: none; background: transparent;
    padding: 4px 10px 4px 4px;
    border-radius: 10px;
    cursor: pointer;
    transition: background .15s;
}
.hdr-user-btn:hover { background: #f1f5f9; }
.hdr-user-photo {
    width: 36px; height: 36px;
    border-radius: 50%; object-fit: cover;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px #e2e8f0;
}
.user-avatar-circle {
    width: 36px; height: 36px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: 600; color: #fff;
    flex-shrink: 0;
}
.hdr-user-info { display: flex; flex-direction: column; line-height: 1.15; text-align: left; }
.hdr-user-name { font-size: 13px; font-weight: 600; color: #1e293b; }
.hdr-user-role { font-size: 11px; color: #94a3b8; font-weight: 500; }
.hdr-user-chev { font-size: 10px; color: #94a3b8; margin-left: 2px; }

/* ── Fixed left sidebar ─────────────────────────────────────────── */
.app-sidebar {
    position: fixed;
    left: 0; top: var(--hdr-h); bottom: 0;
    width: var(--side-w);
    background: var(--side-bg);
    background-image: linear-gradient(180deg, var(--side-bg) 0%, var(--side-bg-2) 100%);
    display: flex;
    flex-direction: column;
    z-index: 1040;
    border-right: 1px solid rgba(255,255,255,.04);
}
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 14px 12px;
}
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.07); border-radius: 3px; }
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.14); }
.sidebar-footer {
    padding: 10px 12px;
    border-top: 1px solid var(--side-border);
}

/* ── Top-level menu item (leaf, no children) ───────────────────── */
.m-item {
    position: relative;
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px;
    margin-bottom: 2px;
    border-radius: 8px;
    color: var(--side-text);
    text-decoration: none !important;
    font-size: 13.5px; font-weight: 500;
    transition: background .15s, color .15s;
    cursor: pointer;
}
.m-item:hover { background: var(--side-hover); color: #fff; }
.m-item.active {
    background: var(--accent-soft);
    color: #fff;
    box-shadow: inset 3px 0 0 var(--accent);
}
.m-item .m-icon {
    width: 20px; flex-shrink: 0;
    font-size: 14px; text-align: center;
    color: var(--side-text-dim);
}
.m-item:hover .m-icon, .m-item.active .m-icon { color: #fff; }
.m-item .m-label { flex: 1; }

/* ── Group (collapsible header + children) ─────────────────────── */
.m-group { margin-bottom: 2px; }
.m-group-head {
    width: 100%;
    display: flex; align-items: center; gap: 12px;
    background: transparent; border: none;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--side-text);
    font-size: 13.5px; font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: background .15s, color .15s;
}
.m-group-head:hover { background: var(--side-hover); color: #fff; }
.m-group-head .m-icon {
    width: 20px; flex-shrink: 0;
    font-size: 14px; text-align: center;
    color: var(--side-text-dim);
}
.m-group-head:hover .m-icon { color: #fff; }
.m-group-head .m-label { flex: 1; }
.m-group-head .m-chev {
    font-size: 10px; color: var(--side-text-dim);
    transition: transform .2s;
}
.m-group.open > .m-group-head .m-chev { transform: rotate(90deg); }
.m-group.active > .m-group-head {
    color: #fff;
    background: rgba(59,130,246,.10);
}
.m-group.active > .m-group-head .m-icon { color: var(--accent); }

/* Children slot (animated collapse) */
.m-children {
    max-height: 0;
    overflow: hidden;
    transition: max-height .25s ease;
    margin-left: 6px;
    padding-left: 22px;
    border-left: 1px dashed rgba(255,255,255,.08);
}
.m-group.open > .m-children { max-height: 600px; padding-top: 4px; padding-bottom: 4px; }

/* Sub-item */
.m-sub {
    position: relative;
    display: flex; align-items: center; gap: 10px;
    padding: 7px 10px;
    border-radius: 6px;
    color: var(--side-text-dim);
    text-decoration: none !important;
    font-size: 12.5px; font-weight: 500;
    transition: background .15s, color .15s;
}
.m-sub:hover { color: #fff; background: var(--side-hover); }
.m-sub .m-dot { font-size: 5px; color: rgba(255,255,255,.25); flex-shrink: 0; transition: color .15s, transform .15s; }
.m-sub:hover .m-dot { color: var(--side-text); }
.m-sub.active { color: #fff; background: var(--accent-soft); font-weight: 600; }
.m-sub.active .m-dot { color: var(--accent); transform: scale(1.6); }

/* Logout footer */
.m-logout { color: #fca5a5 !important; }
.m-logout .m-icon { color: #fca5a5 !important; }
.m-logout:hover { background: rgba(239,68,68,.15); color: #fecaca !important; }
.m-logout:hover .m-icon { color: #fecaca !important; }

/* Search mode — open all groups so matches show */
.app-sidebar.searching .m-group { }
.app-sidebar.searching .m-group .m-children { max-height: 600px; padding-top: 4px; padding-bottom: 4px; }
.m-hidden { display: none !important; }

/* Mobile backdrop */
.sidebar-backdrop {
    display: none;
    position: fixed; inset: var(--hdr-h) 0 0 0;
    background: rgba(15,23,42,.45);
    z-index: 1035;
}

/* ── Page area ──────────────────────────────────────────────────── */
.app-page {
    margin-left: var(--side-w);
    padding-top: var(--hdr-h);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Breadcrumb bar (replaces old sub-tabs) */
.app-crumbs {
    position: sticky;
    top: var(--hdr-h);
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    display: flex; align-items: center; justify-content: space-between;
    height: 44px;
    padding: 0 24px;
    z-index: 1030;
}
.crumbs-nav { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.crumb-home { color: #94a3b8; display: inline-flex; align-items: center; }
.crumb-home:hover { color: var(--accent); }
.crumb-sep { font-size: 9px; color: #cbd5e1; }
.crumb-mod { color: #64748b; font-weight: 500; }
.crumb-page { color: #0f172a; font-weight: 600; }
.crumbs-date { font-size: 12px; color: #94a3b8; font-weight: 500; }

/* Main content */
.app-content { flex: 1; background: #f8fafc; padding: 24px; }

/* Footer */
.app-footer {
    background: #fff;
    border-top: 1px solid #e2e8f0;
    padding: 12px 24px;
    display: flex; align-items: center; justify-content: space-between;
    font-size: 12px; color: #94a3b8;
}
.app-footer strong { color: #374151; }
.app-footer a { color: #94a3b8; text-decoration: none; }
.app-footer a:hover { color: #374151; }

/* ══════════════════════════════════════════════════════════════════
   VARIABLES + BASE
   ══════════════════════════════════════════════════════════════════ */

/* ── Variables ─────────────────────────────────────────────────── */
:root {
    --primary:       #3b82f6;
    --primary-dark:  #2563eb;
    --success:       #10b981;
    --warning:       #f59e0b;
    --danger:        #ef4444;
    --info:          #06b6d4;
    --purple:        #8b5cf6;
    --body-bg:       #f1f5f9;
    --card-bg:       #ffffff;
    --text-primary:  #1e293b;
    --text-muted:    #64748b;
    --border:        #e2e8f0;
    --shadow:        0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
    --shadow-md:     0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -1px rgba(0,0,0,.06);
}

/* ── Base ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
body { font-family: 'Inter', sans-serif; color: #1e293b; margin: 0; }
a { text-decoration: none; }
h1,h2,h3,h4,h5,h6 { font-weight: 600; }

/* ── Cards ─────────────────────────────────────────────────────── */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
}
.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border);
    padding: 16px 20px;
    font-weight: 600;
    font-size: 15px;
    border-radius: 12px 12px 0 0 !important;
}
.card-body  { padding: 20px; }
.card-footer { padding: 14px 20px; }

/* ── Stat Cards ─────────────────────────────────────────────────── */
.stat-card {
    border-radius: 12px; padding: 20px; color: white;
    position: relative; overflow: hidden;
    box-shadow: var(--shadow-md); border: none;
}
.stat-card::before {
    content: ''; position: absolute;
    top: -20px; right: -20px;
    width: 100px; height: 100px;
    border-radius: 50%; background: rgba(255,255,255,.1);
}
.stat-card .stat-icon {
    width: 48px; height: 48px; border-radius: 12px;
    background: rgba(255,255,255,.2);
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; margin-bottom: 12px;
}
.stat-card .stat-value  { font-size: 28px; font-weight: 700; line-height: 1; }
.stat-card .stat-label  { font-size: 13px; opacity: .85; margin-top: 4px; }
.stat-card .stat-trend  { font-size: 12px; opacity: .8; margin-top: 8px; }
.bg-stat-blue   { background: linear-gradient(135deg, #3b82f6, #1d4ed8); }
.bg-stat-green  { background: linear-gradient(135deg, #10b981, #047857); }
.bg-stat-orange { background: linear-gradient(135deg, #f59e0b, #d97706); }
.bg-stat-red    { background: linear-gradient(135deg, #ef4444, #b91c1c); }
.bg-stat-purple { background: linear-gradient(135deg, #8b5cf6, #6d28d9); }
.bg-stat-teal   { background: linear-gradient(135deg, #06b6d4, #0e7490); }
.bg-stat-pink   { background: linear-gradient(135deg, #ec4899, #be185d); }
.bg-stat-indigo { background: linear-gradient(135deg, #6366f1, #4338ca); }

/* ── Badges ─────────────────────────────────────────────────────── */
.badge { font-size: 11px; font-weight: 500; padding: 4px 10px; border-radius: 6px; }
.status-active   { background: #dcfce7; color: #166534; }
.status-inactive { background: #f1f5f9; color: #64748b; }
.status-pending  { background: #fef3c7; color: #92400e; }
.status-approved { background: #dcfce7; color: #166534; }
.status-rejected { background: #fee2e2; color: #991b1b; }
.status-open     { background: #dbeafe; color: #1e40af; }
.status-closed   { background: #f1f5f9; color: #64748b; }
.status-new      { background: #e0f2fe; color: #0369a1; }
.status-won      { background: #dcfce7; color: #166534; }
.status-lost     { background: #fee2e2; color: #991b1b; }
.priority-high   { background: #fee2e2; color: #991b1b; }
.priority-medium { background: #fef3c7; color: #92400e; }
.priority-low    { background: #dcfce7; color: #166534; }

/* ── Tables ─────────────────────────────────────────────────────── */
.table { font-size: 13.5px; }
.table th {
    font-weight: 600; color: var(--text-muted);
    font-size: 12px; text-transform: uppercase; letter-spacing: .5px;
    border-bottom: 2px solid var(--border); background: #f8fafc;
}
.table td { vertical-align: middle; border-bottom: 1px solid var(--border); padding: 12px 14px; }
.table tbody tr:hover { background: #f8fafc; }
.table-responsive { border-radius: 12px; overflow: hidden; }

/* ── Buttons ────────────────────────────────────────────────────── */
.btn        { font-size: 13.5px; font-weight: 500; border-radius: 8px; padding: 8px 16px; }
.btn-sm     { padding: 5px 12px; font-size: 12.5px; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-icon   { width: 32px; height: 32px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; }

/* ── Forms ──────────────────────────────────────────────────────── */
.form-control, .form-select {
    border: 1px solid var(--border); border-radius: 8px;
    font-size: 14px; padding: 9px 13px; color: #1e293b;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59,130,246,.1);
}
.form-label { font-size: 13px; font-weight: 500; color: #374151; margin-bottom: 5px; }
.input-group-text { border-radius: 8px; background: #f8fafc; border-color: var(--border); font-size: 13px; }

/* ── Page Header ────────────────────────────────────────────────── */
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 24px; padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}
.page-header h1 { font-size: 22px; margin: 0; color: #1e293b; }
.page-header p  { color: var(--text-muted); font-size: 13px; margin: 2px 0 0; }

/* ── Avatar ─────────────────────────────────────────────────────── */
.avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--purple));
    color: white; display: inline-flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 13px; flex-shrink: 0;
}
.avatar-lg { width: 64px; height: 64px; font-size: 22px; }
.avatar-xl { width: 96px; height: 96px; font-size: 32px; }

/* ── Filter Bar ─────────────────────────────────────────────────── */
.filter-bar {
    background: var(--card-bg); border: 1px solid var(--border);
    border-radius: 12px; padding: 16px 20px;
    margin-bottom: 20px; box-shadow: var(--shadow);
}

/* ── Empty State ────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state i { font-size: 48px; opacity: .3; margin-bottom: 16px; display: block; }
.empty-state h5 { font-size: 16px; color: #374151; }

/* ── Alerts ─────────────────────────────────────────────────────── */
.alert { border-radius: 10px; border: none; font-size: 14px; }
.alert-success { background: #dcfce7; color: #166534; }
.alert-danger  { background: #fee2e2; color: #991b1b; }

/* ── Login ──────────────────────────────────────────────────────── */
.login-wrapper {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #0b1448 0%, #1a237e 50%, #283593 100%);
}
.login-card {
    width: 420px; background: white; border-radius: 20px;
    padding: 40px; box-shadow: 0 20px 60px rgba(0,0,0,.3);
}

/* ── Payslip ────────────────────────────────────────────────────── */
.payslip { max-width: 800px; margin: 0 auto; background: white; padding: 40px; border-radius: 12px; }
.payslip-header { border-bottom: 3px solid var(--primary); padding-bottom: 20px; margin-bottom: 24px; }

/* ── Timeline ───────────────────────────────────────────────────── */
.timeline { position: relative; padding-left: 24px; }
.timeline::before { content: ''; position: absolute; left: 8px; top: 0; bottom: 0; width: 2px; background: var(--border); }
.timeline-item { position: relative; padding-bottom: 20px; }
.timeline-dot { position: absolute; left: -20px; top: 4px; width: 14px; height: 14px; border-radius: 50%; background: var(--primary); border: 2px solid white; box-shadow: 0 0 0 2px var(--primary); }
.timeline-content { background: #f8fafc; border-radius: 10px; padding: 12px 16px; border: 1px solid var(--border); }

/* ── Kanban ─────────────────────────────────────────────────────── */
.kanban-col { min-width: 220px; background: #f8fafc; border-radius: 12px; padding: 14px; }
.kanban-col-title { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); margin-bottom: 12px; }
.kanban-card { background: white; border-radius: 10px; padding: 14px; margin-bottom: 10px; border: 1px solid var(--border); box-shadow: var(--shadow); font-size: 13px; }

/* ── Breadcrumb ─────────────────────────────────────────────────── */
.breadcrumb { font-size: 13px; }
.breadcrumb-item a { color: var(--primary); }
.breadcrumb-item.active { color: var(--text-muted); }

/* ── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 991.98px) {
    .hdr-search { max-width: 280px; }
    .hdr-left { min-width: auto; }
    .hdr-user-info { display: none; }
}

@media (max-width: 767.98px) {
    .app-sidebar {
        transform: translateX(-100%);
        transition: transform .25s ease;
        box-shadow: 4px 0 24px rgba(0,0,0,.25);
    }
    body.sidebar-open .app-sidebar { transform: translateX(0); }
    body.sidebar-open .sidebar-backdrop { display: block; }
    .app-page { margin-left: 0; }
    .hdr-search { display: none; }
    .hdr-left .app-logo-text { display: none; }
    .app-content { padding: 16px; }
    .crumbs-date { display: none; }
    .app-crumbs { padding: 0 16px; }
}

@media print {
    .app-sidebar, .app-header, .app-crumbs, .app-footer, .sidebar-backdrop { display: none !important; }
    .app-page { margin-left: 0 !important; padding-top: 0 !important; }
    .app-content { padding: 0 !important; background: #fff !important; }
}
