/* =============================================
   TaskManager — Responsive Mobile-First CSS
   ============================================= */

/* ── Reset & Base ─────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { font-size: 14px; }

/* ── CSS Variables ───────────────────────── */
:root {
    --sidebar-w: 240px;
    --topbar-h: 52px;
    --transition: 0.25s ease;
    --radius: 10px;
    --radius-sm: 6px;
}

/* ══════════════════════════════════════════
   SIDEBAR
══════════════════════════════════════════ */
#sidebar {
    width: var(--sidebar-w);
    min-height: 100vh;
    flex-shrink: 0;
    transition: width var(--transition), transform var(--transition);
    z-index: 300;
}

/* Desktop collapsed */
body.sidebar-hidden #sidebar {
    width: 0;
    overflow: hidden;
}

/* Mobile: sidebar is fixed overlay */
@media (max-width: 767.98px) {
    #sidebar {
        position: fixed;
        top: 0; left: 0;
        height: 100%;
        width: 0;
        overflow: hidden;
        transform: translateX(-100%);
        min-height: 100vh;
    }
    body.mob-nav-open #sidebar {
        width: var(--sidebar-w);
        transform: translateX(0);
    }
    /* Overlay backdrop */
    body.mob-nav-open::before {
        content: '';
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.45);
        z-index: 290;
    }
}

#sidebar .nav-link {
    padding: 0.6rem 1.1rem;
    font-size: 0.875rem;
    border-radius: 0;
    transition: background 0.15s;
    white-space: nowrap;
}
#sidebar .nav-link:hover  { background: rgba(255,255,255,0.08); }
#sidebar .nav-link.active { font-weight: 600; }
.sidebar-brand { letter-spacing: 0.02em; }

/* ══════════════════════════════════════════
   LAYOUT
══════════════════════════════════════════ */
#wrapper { min-height: 100vh; }

.main-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* Topbar */
#topbar {
    position: sticky;
    top: 0;
    z-index: 200;
    min-height: var(--topbar-h);
}

/* Main padding */
main.content-area {
    padding: 1.25rem;
    flex: 1;
}
@media (max-width: 575.98px) {
    main.content-area { padding: 0.75rem; }
}

/* ══════════════════════════════════════════
   CARDS
══════════════════════════════════════════ */
.card { border-radius: var(--radius); }
.card-header {
    border-radius: var(--radius) var(--radius) 0 0 !important;
    font-size: 0.9rem;
    padding: 0.7rem 1.1rem;
}

/* ══════════════════════════════════════════
   TABLES — Mobile stacking
══════════════════════════════════════════ */
.table thead th {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6c757d;
    white-space: nowrap;
}
.table tbody tr:hover td { background: rgba(13,110,253,0.04); }

/* Scroll wrapper for wide tables on mobile */
.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.table-scroll .table { min-width: 640px; }

/* Mobile card-style rows (opt-in with .table-cards class) */
@media (max-width: 575.98px) {
    .table-cards thead  { display: none; }
    .table-cards tbody tr {
        display: block;
        margin-bottom: 0.75rem;
        border: 1px solid #dee2e6;
        border-radius: var(--radius-sm);
        padding: 0.5rem 0.75rem;
        background: #fff;
    }
    .table-cards td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 4px 0;
        border: none;
        font-size: 0.8rem;
    }
    .table-cards td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #6c757d;
        font-size: 0.72rem;
        text-transform: uppercase;
        margin-right: 8px;
        flex-shrink: 0;
    }
}

/* ══════════════════════════════════════════
   BADGES
══════════════════════════════════════════ */
.badge-success   { background-color: #198754 !important; color: #fff; }
.badge-primary   { background-color: #0d6efd !important; color: #fff; }
.badge-warning   { background-color: #ffc107 !important; color: #212529; }
.badge-info      { background-color: #0dcaf0 !important; color: #212529; }
.badge-secondary { background-color: #6c757d !important; color: #fff; }
.badge-danger    { background-color: #dc3545 !important; color: #fff; }

/* ══════════════════════════════════════════
   STATUS DOTS
══════════════════════════════════════════ */
.status-dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    margin-right: 4px;
    flex-shrink: 0;
}
.dot-completed  { background: #198754; }
.dot-inprogress { background: #0d6efd; }
.dot-pending    { background: #ffc107; }
.dot-critical   { background: #dc3545; }
.dot-onhold     { background: #6c757d; }
.dot-cancelled  { background: #adb5bd; }

/* ══════════════════════════════════════════
   STAT PILLS
══════════════════════════════════════════ */
.stat-pill {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    border: 1px solid transparent;
    white-space: nowrap;
}
.stat-pill.total    { background:#e7f1ff; color:#0d4fa3; border-color:#b6d0f7; }
.stat-pill.completed{ background:#d1fae5; color:#065f46; border-color:#6ee7b7; }
.stat-pill.progress { background:#dbeafe; color:#1d4ed8; border-color:#93c5fd; }
.stat-pill.pending  { background:#fef9c3; color:#92400e; border-color:#fde68a; }
.stat-pill.critical { background:#fee2e2; color:#991b1b; border-color:#fca5a5; }
.stat-pill.overdue  { background:#fff1f2; color:#9f1239; border-color:#fda4af; }

/* Scrollable pill row on mobile */
.pill-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 0.75rem;
}
@media (max-width: 575.98px) {
    .pill-row {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
    }
    .pill-row::-webkit-scrollbar { height: 3px; }
}

/* ══════════════════════════════════════════
   KPI CARDS
══════════════════════════════════════════ */
.kpi-icon {
    width: 44px; height: 44px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.kpi-val  { font-size: 1.6rem; font-weight: 700; line-height: 1; }
.kpi-label{ font-size: 0.78rem; color: #6c757d; margin-top: 2px; }
.kpi-sub  { font-size: 0.7rem; color: #adb5bd; margin-top: 1px; }

@media (max-width: 575.98px) {
    .kpi-val  { font-size: 1.35rem; }
    .kpi-label{ font-size: 0.72rem; }
}

/* ══════════════════════════════════════════
   FORMS
══════════════════════════════════════════ */
.form-select, .form-control {
    font-size: 0.875rem;
    border-radius: var(--radius-sm);
}
.form-label { font-size: 0.82rem; margin-bottom: 3px; font-weight: 600; }

/* Minimum touch target 44px */
.form-control, .form-select, .btn {
    min-height: 38px;
}
@media (max-width: 767.98px) {
    .form-control, .form-select { font-size: 16px !important; } /* Prevents iOS zoom */
}

/* ══════════════════════════════════════════
   BUTTONS
══════════════════════════════════════════ */
.btn { border-radius: var(--radius-sm); }

/* Full-width buttons on mobile for action rows */
@media (max-width: 575.98px) {
    .btn-mobile-full { width: 100%; }
    .gap-mobile-2 > * { margin-bottom: 0.5rem; }
}

/* ══════════════════════════════════════════
   PROGRESS BAR
══════════════════════════════════════════ */
.progress { border-radius: 10px; background: #e9ecef; }
.progress-bar { border-radius: 10px; transition: width 0.4s ease; }

/* ══════════════════════════════════════════
   OVERDUE ROW
══════════════════════════════════════════ */
.table-danger td { background-color: rgba(220,53,69,0.05) !important; }

/* ══════════════════════════════════════════
   LOGIN PAGE
══════════════════════════════════════════ */
.login-page-bg {
    min-height: 100vh;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 40%, #0f3460 100%);
    display: flex; align-items: center; justify-content: center;
    padding: 1rem;
}
.login-card {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
    overflow: hidden;
    width: 100%;
    max-width: 430px;
}
.login-header {
    background: linear-gradient(135deg, #1565c0, #0d47a1);
    padding: 2rem 1.5rem;
    text-align: center;
    color: #fff;
}
.login-brand-icon {
    width: 60px; height: 60px;
    background: rgba(255,255,255,0.2);
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 10px;
    font-size: 1.6rem;
}
.login-header h2 { font-size: 1.4rem; font-weight: 700; margin-bottom: 3px; }
.login-header p  { opacity: 0.85; font-size: 0.85rem; margin: 0; }
.login-body { padding: 1.5rem; }

.login-input-group {
    display: flex; align-items: center;
    border: 1.5px solid #dee2e6; border-radius: 10px;
    overflow: hidden; margin-bottom: 12px; background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.login-input-group:focus-within {
    border-color: #1565c0;
    box-shadow: 0 0 0 3px rgba(21,101,192,0.12);
}
.login-input-group .lig-icon {
    padding: 0 11px; color: #6c757d; font-size: 15px;
    background: #f8f9fa; border-right: 1.5px solid #dee2e6;
    align-self: stretch; display: flex; align-items: center;
}
.login-input-group input {
    flex: 1; border: none; outline: none;
    padding: 10px 12px; font-size: 15px;
    background: transparent; color: #212529;
    min-width: 0;
}
.login-input-group .eye-toggle {
    padding: 0 11px; cursor: pointer;
    background: none; border: none;
    color: #6c757d; font-size: 14px;
}
.login-input-group .eye-toggle:hover { color: #1565c0; }

.btn-login {
    width: 100%; padding: 12px;
    background: linear-gradient(135deg, #1565c0, #0d47a1);
    border: none; border-radius: 10px;
    color: #fff; font-size: 15px; font-weight: 600;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.btn-login:active { opacity: 0.9; }

.quick-login-divider {
    display: flex; align-items: center; gap: 10px;
    margin: 1.25rem 0; color: #adb5bd; font-size: 0.78rem;
}
.quick-login-divider::before, .quick-login-divider::after {
    content: ''; flex: 1; height: 1px; background: #dee2e6;
}
.quick-role-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.quick-role-badge {
    border: 1.5px solid #e9ecef; border-radius: 10px;
    padding: 10px 8px; text-align: center; cursor: pointer;
    background: #f8f9fa; transition: all 0.15s;
    -webkit-tap-highlight-color: transparent;
}
.quick-role-badge:active { background: #e7f1ff; border-color: #1565c0; }
.quick-role-badge .qrole { font-weight: 700; font-size: 0.85rem; display: block; margin: 4px 0 2px; }
.quick-role-badge .qcred { font-size: 0.72rem; color: #6c757d; }
.login-footer-bar {
    background: #f8f9fa; padding: 10px 1.5rem;
    text-align: center; font-size: 0.72rem;
    color: #6c757d; border-top: 1px solid #dee2e6;
}
.login-error-box {
    background: #fff5f5; border-left: 4px solid #dc3545;
    padding: 10px 14px; margin-bottom: 14px;
    font-size: 0.85rem; color: #dc3545;
    display: none; align-items: center; gap: 8px;
}
.login-error-box.show { display: flex; }

/* ══════════════════════════════════════════
   TICKET / CLIENT SEARCH (Create Ticket)
══════════════════════════════════════════ */
.cs-wrap { position: relative; }
.cs-box {
    display: flex; align-items: center;
    border: 1.5px solid #ced4da; border-radius: var(--radius-sm);
    overflow: hidden; background: #fff;
}
.cs-box:focus-within { border-color: #1565c0; box-shadow: 0 0 0 3px rgba(21,101,192,.12); }
.cs-ico {
    padding: 0 10px; background: #f8f9ff;
    border-right: 1px solid #ced4da; color: #1565c0;
    font-size: 13px; display: flex; align-items: center; flex-shrink: 0;
}
#csInput {
    flex: 1; border: none; outline: none;
    padding: 8px 10px; font-size: 0.875rem;
    background: transparent; color: #212529; min-width: 0;
}
@media (max-width: 767.98px) { #csInput { font-size: 16px !important; } }
#csClear {
    padding: 0 10px; cursor: pointer; background: none;
    border: none; border-left: 1px solid #ced4da;
    color: #adb5bd; font-size: 12px; display: none; align-items: center;
}
#csDrop {
    display: none; position: absolute; top: calc(100% + 2px);
    left: 0; right: 0; z-index: 9999;
    background: #fff; border: 1.5px solid #1565c0;
    border-radius: 0 0 8px 8px; max-height: 240px;
    overflow-y: auto; box-shadow: 0 8px 24px rgba(21,101,192,.15);
}
.cs-item { padding: 9px 14px; cursor: pointer; border-bottom: 1px solid #f5f5f5; }
.cs-item:last-child { border-bottom: none; }
.cs-item:hover, .cs-item.hl { background: #e8f0fe; }
.cs-nm { font-weight: 600; font-size: 0.875rem; color: #1a237e; }
.cs-sub { font-size: 0.74rem; color: #6c757d; margin-top: 1px; }
.cs-tag {
    display: inline-block; font-size: 0.68rem; font-weight: 600;
    padding: 1px 7px; border-radius: 10px;
    background: #e3f2fd; color: #1565c0; margin-left: 5px;
}
.cs-msg { padding: 14px; text-align: center; color: #6c757d; font-size: 0.82rem; }
.cs-badge {
    display: none; align-items: center; gap: 5px;
    margin-top: 5px; padding: 3px 10px;
    background: #e8f5e9; border: 1px solid #a5d6a7;
    border-radius: 12px; font-size: 0.75rem; color: #2e7d32; width: fit-content;
}

/* ══════════════════════════════════════════
   RESPONSIVE HELPERS
══════════════════════════════════════════ */

/* Hide on mobile */
@media (max-width: 575.98px) {
    .d-xs-none { display: none !important; }
}

/* Stack two-column forms on mobile */
@media (max-width: 767.98px) {
    .form-two-col .col-md-6 { margin-bottom: 0.5rem; }
    .border-end-md { border-right: none !important; }
}

/* Compact header on mobile */
@media (max-width: 575.98px) {
    #topbar .topbar-right { gap: 6px !important; }
    #topbar .topbar-date  { display: none !important; }
}

/* Compact page titles on mobile */
@media (max-width: 575.98px) {
    h4.page-title { font-size: 1.1rem; }
    h5.page-title { font-size: 1rem; }
}

/* Stat pill row compact */
@media (max-width: 575.98px) {
    .stat-pill { padding: 3px 8px; font-size: 0.72rem; }
}

/* Modal full width on mobile */
@media (max-width: 575.98px) {
    .modal-dialog { margin: 0.5rem; }
    .modal-dialog-sm { max-width: calc(100vw - 1rem); }
}

/* Card padding reduced on mobile */
@media (max-width: 575.98px) {
    .card-body { padding: 0.75rem; }
    .card-header { padding: 0.6rem 0.75rem; }
}

/* Quick-status buttons full width on mobile */
@media (max-width: 575.98px) {
    .quick-status-btn { font-size: 0.8rem; text-align: left; }
}

/* Tab bar scroll on mobile */
.tab-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.tab-scroll::-webkit-scrollbar { display: none; }

/* Misc */
pre { font-size: 0.78rem; line-height: 1.6; }
.form-range::-webkit-slider-thumb { background: #0d6efd; }
.table-danger td { background-color: rgba(220,53,69,0.05) !important; }
