/* ============================================
   Tech CRM - Main Stylesheet
   ============================================ */

:root {
    --primary-color: #0d6efd;
    --navbar-height: 62px;
    --sidebar-width: 264px;
    --sidebar-collapsed-width: 62px;
    --brand-bg: #0D1226;
    --brand-text: #FEFBFC;
    --sidebar-bg: #0D1226;
    --sidebar-text: #FEFBFC;
    --primary-gradient-start: #667eea;
    --primary-gradient-end: #764ba2;
    --sidebar-transition: 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f8f9fa;
}

/* ============================================
   NAVBAR STYLING  –  sticky so sidebar stays aligned
   ============================================ */

.navbar {
    position: sticky;
    top: 0;
    z-index: 1040;
    background-color: var(--brand-bg);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
    min-height: var(--navbar-height);
}

/* Navbar brand and text */
.navbar .navbar-brand,
.navbar .navbar-brand:hover,
.navbar .text-white,
.navbar span {
    color: var(--brand-text) !important;
}

/* ── Dashboard Switcher pill ─────────────────────────────────────────────── */
.dash-switcher {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.10);
    border: 1px solid rgba(255, 255, 255, 0.20);
    border-radius: 999px;
    padding: 2px;
    gap: 0;
}

.dash-switcher-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 14px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.65);
    text-decoration: none;
    transition: background 0.18s, color 0.18s;
    white-space: nowrap;
}

.dash-switcher-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.12);
}

.dash-switcher-btn.active {
    background: linear-gradient(135deg, var(--primary-gradient-start), var(--primary-gradient-end));
    color: #fff;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.45);
}

/* ── Branch view switcher (navbar) ───────────────────────────────────────── */
.branch-switcher-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    color: #fff;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.22);
    white-space: nowrap;
}
.branch-switcher-btn:hover,
.branch-switcher-btn:focus {
    color: #fff;
    background: rgba(255, 255, 255, 0.20);
    border-color: rgba(255, 255, 255, 0.35);
}
.branch-switcher-btn::after {
    margin-left: 4px;
}
/* ─────────────────────────────────────────────────────────────────────────── */

/* Navbar border bottom accent */
.navbar::after {
    content: '';
    display: block;
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--primary-gradient-start), var(--primary-gradient-end));
}

.navbar-brand {
    font-size: 1.4rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 10px;
}

.navbar-brand i {
    font-size: 1.8rem;
}

/* ============================================
   NOTIFICATION BELL (navbar)
   ============================================ */

.nav-notif-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    background: rgba(255,255,255,0.12);
    border-radius: 8px;
    color: var(--brand-text);
    font-size: 1.1rem;
    text-decoration: none;
    transition: background 0.2s;
}

.nav-notif-btn:hover {
    background: rgba(255,255,255,0.25);
    color: var(--brand-text);
}

.notif-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    background: #e74c3c;
    color: white;
    font-size: 0.6rem;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    line-height: 1;
    border: 1.5px solid var(--brand-bg);
}

/* Sidebar toggle button in navbar */
#sidebarToggleBtn {
    background: rgba(255,255,255,0.15);
    border: none;
    color: white;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    transition: background 0.2s ease;
    flex-shrink: 0;
}

#sidebarToggleBtn:hover {
    background: rgba(255,255,255,0.28);
}

/* ============================================
   MAIN CONTAINER LAYOUT
   ============================================ */

.app-container {
    display: flex;
    min-height: calc(100vh - var(--navbar-height));
    position: relative;
}

/* ============================================
   SIDEBAR STYLING
   ============================================ */

.sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    padding-top: 0.75rem;

    /* Stick to top of viewport right below the sticky navbar */
    position: sticky;
    top: var(--navbar-height);
    height: calc(100vh - var(--navbar-height));
    overflow-y: auto;
    overflow-x: hidden;

    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.12);
    z-index: 1030;
    flex-shrink: 0;

    transition: width var(--sidebar-transition);
}

/* Collapsed sidebar — icons only */
.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

/* Sidebar scrollbar */
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }

/* ---- Sidebar collapse toggle button (inside sidebar) ---- */
.sidebar-collapse-btn {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 4px 10px 10px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    margin-bottom: 0.5rem;
}

.sidebar-collapse-btn button {
    background: rgba(255,255,255,0.1);
    border: none;
    color: rgba(255,255,255,0.7);
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, transform 0.28s ease;
    font-size: 1rem;
    flex-shrink: 0;
}

.sidebar-collapse-btn button:hover {
    background: rgba(255,255,255,0.2);
    color: white;
}

/* Rotate the chevron when collapsed */
.sidebar.collapsed .sidebar-collapse-btn button {
    transform: rotate(180deg);
}

/* ---- Sidebar sections ---- */
.sidebar-section {
    margin-bottom: 0.65rem;
    padding: 0 0.35rem;
}

.sidebar-title {
    padding: 10px 16px 4px;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.38);
    letter-spacing: 0.7px;
    margin-top: 0.35rem;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 8px;
    overflow: hidden;
}

.sidebar-title i {
    font-size: 1rem;
    flex-shrink: 0;
    width: 30px;
    text-align: center;
}

/* Hide text labels when collapsed */
.sidebar .link-text,
.sidebar-title .link-text {
    transition: opacity var(--sidebar-transition), width var(--sidebar-transition);
    opacity: 1;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar.collapsed .link-text,
.sidebar.collapsed .sidebar-title .link-text {
    opacity: 0;
    width: 0;
    pointer-events: none;
}

/* ---- Sidebar links (top links + accordion parents share same size) ---- */
.sidebar a,
.sidebar button.nav-group-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    min-height: 46px;
    width: 100%;
    color: var(--sidebar-text);
    text-decoration: none;
    background: transparent;
    border: none;
    border-left: 3px solid transparent;
    border-radius: 0 8px 8px 0;
    white-space: nowrap;
    overflow: hidden;
    cursor: pointer;
    text-align: left;
    font: inherit;
    font-size: 0.95rem;
    font-weight: 400;
    line-height: 1.3;
    box-sizing: border-box;
    appearance: none;
    -webkit-appearance: none;
    transition: background 0.2s ease, border-left-color 0.2s ease, padding 0.28s ease;
}

.sidebar a i,
.sidebar button.nav-group-btn > i:first-child {
    font-size: 1.15rem;
    flex-shrink: 0;
    width: 28px;
    text-align: center;
}

.sidebar a:hover,
.sidebar button.nav-group-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-left-color: var(--primary-color);
}

.sidebar a.active,
.sidebar .nav-group.is-current > button.nav-group-btn {
    background-color: rgba(13, 110, 253, 0.25);
    border-left-color: var(--primary-color);
    color: white;
    font-weight: 500;
}

/* Accordion groups — click parent to reveal children */
.nav-group {
    margin: 0;
    padding: 0 0.35rem;
    position: relative;
}

.nav-group > button.nav-group-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    min-height: 46px;
    width: 100%;
    color: var(--sidebar-text);
    background: transparent;
    border: none;
    border-left: 3px solid transparent;
    border-radius: 0 8px 8px 0;
    box-sizing: border-box;
    font: inherit;
    font-size: 0.95rem;
    font-weight: 400;
    line-height: 1.3;
    cursor: pointer;
    user-select: none;
    text-align: left;
    appearance: none;
    -webkit-appearance: none;
}

.nav-group > button.nav-group-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-left-color: var(--primary-color);
}

.nav-group.is-current > button.nav-group-btn {
    background-color: rgba(13, 110, 253, 0.25);
    border-left-color: var(--primary-color);
    color: white;
    font-weight: 500;
}

.nav-group-btn .nav-chevron {
    margin-left: auto;
    width: 20px;
    font-size: 0.9rem;
    opacity: 0.65;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.nav-group.is-open > .nav-group-btn .nav-chevron {
    transform: rotate(180deg);
}

.nav-sub {
    display: none;
    padding: 2px 0 10px;
}

.nav-group.is-open > .nav-sub {
    display: block;
}

.nav-sub a {
    padding: 10px 14px 10px 52px;
    min-height: 40px;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.82);
}

.nav-sub a i {
    width: 22px;
    font-size: 1rem;
}

/* Collapsed sidebar: hide inline children; flyout appears on click */
.sidebar.collapsed .nav-group > .nav-sub { display: none; }
.sidebar.collapsed .nav-group-btn .nav-chevron { display: none; }

.sidebar.collapsed .nav-group.is-flyout > .nav-sub {
    display: block;
    position: fixed;
    left: calc(var(--sidebar-collapsed-width) + 6px);
    min-width: 200px;
    padding: 8px 0;
    background: var(--sidebar-bg);
    border-radius: 10px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
    z-index: 1100;
}

.sidebar.collapsed .nav-group.is-flyout > .nav-sub a {
    padding: 10px 16px;
}

/* When collapsed, center the icons and hide text */
.sidebar.collapsed a,
.sidebar.collapsed .nav-group > .nav-group-btn {
    padding: 11px 0;
    justify-content: center;
    gap: 0;
    border-left-width: 3px;
    min-height: 46px;
}

/* Bootstrap tooltip for collapsed icons */
.sidebar.collapsed a[data-bs-title],
.sidebar.collapsed a[title] {
    position: relative;
}

/* ============================================
   MAIN CONTENT AREA
   ============================================ */

.main-content {
    flex: 1;
    padding: 2rem;
    min-width: 0; /* prevent flex overflow */
    transition: padding-left var(--sidebar-transition);
}

/* ============================================
   MOBILE — sidebar becomes an overlay drawer
   ============================================ */

@media (max-width: 991.98px) {
    .sidebar {
        /* Off-canvas on mobile */
        position: fixed;
        top: var(--navbar-height);
        left: 0;
        height: calc(100vh - var(--navbar-height));
        transform: translateX(-100%);
        transition: transform var(--sidebar-transition), width var(--sidebar-transition);
        z-index: 1035;
        width: var(--sidebar-width) !important; /* always full width when open */
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    /* Dim overlay */
    #sidebarOverlay {
        display: none;
        position: fixed;
        inset: 0;
        top: var(--navbar-height);
        background: rgba(0,0,0,0.45);
        z-index: 1034;
    }

    #sidebarOverlay.visible {
        display: block;
    }

    .main-content {
        margin-left: 0 !important;
        padding: 1rem;
    }

    /* Hide sidebar collapse chevron button on mobile (use overlay instead) */
    .sidebar-collapse-btn {
        display: none;
    }
}

/* ============================================
   PAGE HEADER
   ============================================ */

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #e9ecef;
}

.page-header h1 {
    font-size: 2rem;
    color: #2c3e50;
    margin: 0;
}

/* ============================================
   CARDS
   ============================================ */

.card {
    border: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.14);
}

.card-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    font-weight: bold;
}

/* ============================================
   STAT CARDS
   ============================================ */

.stat-card {
    background: linear-gradient(135deg, var(--primary-gradient-start) 0%, var(--primary-gradient-end) 100%);
    color: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.stat-card.pending  { background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%); }
.stat-card.in-progress { background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%); }
.stat-card.completed { background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%); }
.stat-card.revenue   { background: linear-gradient(135deg, #fa709a 0%, #fee140 100%); }
.stat-card.total     { background: linear-gradient(135deg, #30cfd0 0%, #330867 100%); }

.stat-value {
    font-size: 2.5rem;
    font-weight: bold;
    margin: 0;
}

.stat-label {
    font-size: 0.9rem;
    opacity: 0.9;
    margin: 0;
}

/* ============================================
   TABLES
   ============================================ */

.table { background-color: white; }
.table thead { background-color: #f8f9fa; }
.table tbody tr:hover { background-color: #f8f9fa; }

/* ============================================
   BUTTONS
   ============================================ */

.btn {
    border-radius: 5px;
    padding: 8px 16px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.btn-primary { background-color: var(--primary-color); border-color: var(--primary-color); }
.btn-primary:hover {
    background-color: #0b5ed7;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(13, 110, 253, 0.3);
    color: white;
    border-color: #0b5ed7;
}

.btn-sm { padding: 5px 12px; font-size: 0.85rem; }

.btn-success:hover { transform: translateY(-2px); box-shadow: 0 4px 10px rgba(25, 135, 84, 0.3); }
.btn-warning:hover { transform: translateY(-2px); box-shadow: 0 4px 10px rgba(255, 193, 7, 0.3); }
.btn-danger:hover  { transform: translateY(-2px); box-shadow: 0 4px 10px rgba(220, 53, 69, 0.3); }
.btn-info:hover    { transform: translateY(-2px); box-shadow: 0 4px 10px rgba(23, 162, 184, 0.3); }

/* ============================================
   ALERTS
   ============================================ */

.alert {
    border-radius: 5px;
    border: none;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ============================================
   FORMS
   ============================================ */

.form-control,
.form-select {
    border: 2px solid #e8e8e8 !important;
    border-radius: 12px !important;
    padding: 1rem 1.25rem !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    font-size: 1rem !important;
    background: #fafafa !important;
    min-height: 50px !important;
    font-weight: 500 !important;
}

.form-control:focus,
.form-select:focus {
    border-color: #667eea !important;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.15) !important;
    background: white !important;
    outline: none !important;
}

.form-control::placeholder { color: #b0b0b0 !important; font-weight: 400 !important; }

.form-control:hover,
.form-select:hover { border-color: #667eea !important; background: white !important; }

textarea.form-control { min-height: 120px !important; resize: vertical; }

.form-label {
    font-weight: 700 !important;
    color: #333 !important;
    margin-bottom: 1rem !important;
    display: flex !important;
    align-items: center !important;
    gap: 0.75rem !important;
    font-size: 1rem !important;
    text-transform: capitalize !important;
    letter-spacing: 0.3px !important;
}

.form-label i { color: #667eea !important; font-size: 1.25rem !important; }

.invalid-feedback {
    color: #dc3545 !important;
    font-size: 0.9rem !important;
    margin-top: 0.5rem !important;
    display: block !important;
    font-weight: 500 !important;
}

/* ============================================
   USER MENU
   ============================================ */

.user-menu {
    display: flex;
    align-items: center;
    gap: 15px;
    color: white;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

/* ============================================
   SCROLLBAR STYLING
   ============================================ */

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: #f1f1f1; }
::-webkit-scrollbar-thumb { background: #888; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #555; }

/* ============================================
   FOOTER
   ============================================ */

footer {
    background-color: var(--brand-bg);
    color: var(--brand-text);
    padding: 1.5rem;
    text-align: center;
}

footer p { margin: 0; }

/* ============================================
   UTILITY CLASSES
   ============================================ */

.shadow-sm  { box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important; }
.shadow-md  { box-shadow: 0 5px 15px rgba(0, 0, 0, 0.15) !important; }
.rounded-lg { border-radius: 8px !important; }

.text-gradient {
    background: linear-gradient(135deg, var(--primary-gradient-start) 0%, var(--primary-gradient-end) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.gradient-bg {
    background: linear-gradient(135deg, var(--primary-gradient-start) 0%, var(--primary-gradient-end) 100%);
}

/* ============================================
   DASHBOARD SPECIFIC
   ============================================ */

.dashboard-header { margin-bottom: 2.5rem; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.chart-container {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* ============================================
   ANIMATIONS
   ============================================ */

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes slideInLeft {
    from { transform: translateX(-20px); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
}

/* ============================================
   LOGIN PAGE STYLES
   ============================================ */

body.login-page {
    background: var(--brand-bg);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    max-width: 450px;
    width: 100%;
}

.login-header {
    background-color: var(--brand-bg);
    color: var(--brand-text);
    padding: 3rem 2rem;
    text-align: center;
}

.login-header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.login-header p { font-size: 0.95rem; opacity: 0.9; margin: 0; }
.login-body { padding: 2.5rem 2rem; }
.login-body .form-group { margin-bottom: 1.5rem; }
.login-body .form-label { font-weight: 600; color: #2c3e50; margin-bottom: 0.5rem; font-size: 0.95rem; }
.login-body .form-control { border: 2px solid #e9ecef; border-radius: 8px; padding: 12px 15px; font-size: 1rem; transition: all 0.3s ease; }
.login-body .form-control:focus { border-color: var(--primary-gradient-start); box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25); }
.login-body .form-control::placeholder { color: #adb5bd; }

.btn-login {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--primary-gradient-start) 0%, var(--primary-gradient-end) 100%);
    color: white;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 1rem;
}

.btn-login:hover { transform: translateY(-2px); box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4); color: white; text-decoration: none; }
.btn-login:active { transform: translateY(0); }

.remember-me { display: flex; align-items: center; gap: 8px; margin-bottom: 1.5rem; font-size: 0.95rem; }
.remember-me input[type="checkbox"] { cursor: pointer; width: 18px; height: 18px; }
.remember-me label { margin: 0; cursor: pointer; flex: 1; }

.divider { text-align: center; margin: 2rem 0; position: relative; color: #adb5bd; font-size: 0.9rem; }
.divider::before { content: ''; position: absolute; top: 50%; left: 0; right: 0; height: 1px; background: #e9ecef; }
.divider span { background: white; padding: 0 10px; position: relative; }

.help-text { text-align: center; margin-top: 1.5rem; font-size: 0.9rem; color: #6c757d; }
.help-text a { color: var(--primary-gradient-start); text-decoration: none; font-weight: 600; }
.help-text a:hover { text-decoration: underline; }

.error-message { background-color: #f8d7da; border: 1px solid #f5c6cb; color: #721c24; padding: 12px 15px; border-radius: 8px; margin-bottom: 1.5rem; }
.error-icon { margin-right: 8px; }

@media (max-width: 480px) {
    .login-header { padding: 2rem 1.5rem; }
    .login-header h1 { font-size: 2rem; }
    .login-body { padding: 2rem 1.5rem; }
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
    .navbar, .sidebar, footer { display: none; }
    .main-content { margin-left: 0 !important; width: 100%; }
}
