/* Flexr Admin Panel - Dark Mode Theme */

/* User photos use the same contract as the app inbox: a real uploaded photo,
   or dark initials when no usable photo exists. */
.user-avatar {
    --avatar-size: 32px;
    width: var(--avatar-size);
    height: var(--avatar-size);
    min-width: var(--avatar-size);
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 50%;
    background: #15191e;
    border: 1px solid #3a424c;
    color: #f1f3f5;
    font-size: calc(var(--avatar-size) * 0.36);
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.02em;
    vertical-align: middle;
}
.user-avatar-initials {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.user-avatar img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ═══════════════════════════════════ */
/* DARK MODE OVERRIDES                */
/* ═══════════════════════════════════ */

/* Body & Content */
.dark-mode .content-wrapper {
    background-color: #1a1d21;
}
.dark-mode .main-header {
    background-color: #1e2227;
    border-bottom: 1px solid #2c3038;
}
.dark-mode .main-footer {
    background-color: #1e2227;
    border-top: 1px solid #2c3038;
    color: #6c757d;
}

/* Cards */
.dark-mode .card {
    background-color: #212529;
    border-color: #2c3038;
}
.dark-mode .card-header {
    border-bottom-color: #2c3038;
}
.dark-mode .card-outline {
    border-top-width: 3px;
}
.dark-mode .bg-light {
    background-color: #2c3038 !important;
    color: #e0e0e0;
}

/* Tables */
.dark-mode .table {
    color: #c4c9ce;
}
.dark-mode .table-hover tbody tr:hover {
    background-color: rgba(255,255,255,0.05);
}
.dark-mode .table-striped tbody tr:nth-of-type(odd) {
    background-color: rgba(255,255,255,0.03);
}
.dark-mode .table th {
    border-top-color: #2c3038;
    border-bottom-color: #2c3038;
    color: #8b929a;
}
.dark-mode .table td {
    border-top-color: #2c3038;
}

/* Tabs */
.dark-mode .nav-tabs {
    border-bottom-color: #2c3038;
}
.dark-mode .nav-tabs .nav-link {
    color: #8b929a;
}
.dark-mode .nav-tabs .nav-link:hover {
    border-color: #2c3038;
    color: #e0e0e0;
}
.dark-mode .nav-tabs .nav-link.active {
    background-color: #212529;
    border-color: #2c3038 #2c3038 #212529;
    color: #fff;
}

/* Forms */
.dark-mode .form-control {
    background-color: #2c3038;
    border-color: #3a3f47;
    color: #e0e0e0;
}
.dark-mode .form-control:focus {
    background-color: #343a40;
    border-color: #007bff;
    color: #fff;
}
.dark-mode .form-control::placeholder {
    color: #6c757d;
}
.dark-mode .input-group-text {
    background-color: #2c3038;
    border-color: #3a3f47;
    color: #adb5bd;
}

/* Pagination */
.dark-mode .page-link {
    background-color: #2c3038;
    border-color: #3a3f47;
    color: #8b929a;
}
.dark-mode .page-item.active .page-link {
    background-color: #007bff;
    border-color: #007bff;
}
.dark-mode .page-item.disabled .page-link {
    background-color: #1e2227;
    border-color: #2c3038;
    color: #4a4f57;
}

/* Breadcrumbs */
.dark-mode .breadcrumb {
    background-color: transparent;
}
.dark-mode .breadcrumb-item a {
    color: #8b929a;
}
.dark-mode .breadcrumb-item.active {
    color: #e0e0e0;
}

/* Alerts */
.dark-mode .alert-success {
    background-color: rgba(40, 167, 69, 0.15);
    border-color: rgba(40, 167, 69, 0.3);
    color: #75d89a;
}
.dark-mode .alert-danger {
    background-color: rgba(220, 53, 69, 0.15);
    border-color: rgba(220, 53, 69, 0.3);
    color: #e88a93;
}
.dark-mode .alert-warning {
    background-color: rgba(255, 193, 7, 0.15);
    border-color: rgba(255, 193, 7, 0.3);
    color: #f0d262;
}

/* ═══════════════════════════════════ */
/* SIDEBAR                            */
/* ═══════════════════════════════════ */

.brand-link {
    border-bottom: 1px solid #4b545c;
}
.brand-link .brand-text {
    font-weight: 600;
}

/* ═══════════════════════════════════ */
/* DASHBOARD STAT CARDS               */
/* ═══════════════════════════════════ */

.small-box .inner h3 {
    font-size: 2.2rem;
    font-weight: 700;
}
.small-box .inner p {
    font-size: 1rem;
}
.small-box:hover {
    transform: translateY(-2px);
    transition: transform 0.2s ease;
    box-shadow: 0 4px 25px rgba(0,0,0,0.4);
}

/* ═══════════════════════════════════ */
/* TABLE IMPROVEMENTS                 */
/* ═══════════════════════════════════ */

.table th {
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ═══════════════════════════════════ */
/* STATUS BADGES                      */
/* ═══════════════════════════════════ */

.badge-open { background-color: #007bff; color: #fff; }
.badge-active { background-color: #17a2b8; color: #fff; }
.badge-ongoing { background-color: #ffc107; color: #1a1d21; }
.badge-completed { background-color: #28a745; color: #fff; }
.badge-cancelled { background-color: #dc3545; color: #fff; }
.badge-disputed { background-color: #e83e8c; color: #fff; }
.badge-approved { background-color: #20c997; color: #fff; }
.badge-pending { background-color: #fd7e14; color: #fff; }
.badge-fixed-price { background-color: #6f42c1; color: #fff; }
.badge-estimate { background-color: #17a2b8; color: #fff; }

/* ═══════════════════════════════════ */
/* CHAT STYLES                        */
/* ═══════════════════════════════════ */

.chat-messages {
    max-height: 600px;
    overflow-y: auto;
    padding: 20px;
    background-color: #1a1d21;
    border-radius: 8px;
}
.chat-message {
    margin-bottom: 12px;
    padding: 10px 15px;
    border-radius: 16px;
    max-width: 70%;
    position: relative;
}
.chat-message.sent {
    background: linear-gradient(135deg, #007bff, #0056b3);
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 4px;
}
.chat-message.received {
    background-color: #2c3038;
    color: #e0e0e0;
    border-bottom-left-radius: 4px;
}
.chat-message.admin-msg {
    background: linear-gradient(135deg, #6f42c1, #5a2d91);
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 4px;
}
.chat-message .sender {
    font-weight: 600;
    font-size: 0.75rem;
    margin-bottom: 4px;
    opacity: 0.8;
}
.chat-message .timestamp {
    font-size: 0.7rem;
    opacity: 0.6;
    margin-top: 4px;
}
.chat-input-area {
    border-top: 1px solid #2c3038;
    padding: 15px;
    background-color: #212529;
}

/* ═══════════════════════════════════ */
/* PRICING DISPLAY                    */
/* ═══════════════════════════════════ */

.price-fixed {
    color: #b07dff;
    font-weight: 700;
}
.price-estimate {
    color: #5bc0de;
    font-weight: 700;
}

/* ═══════════════════════════════════ */
/* JOB DETAIL CARDS                   */
/* ═══════════════════════════════════ */

.info-card {
    border-left: 4px solid #007bff;
}
.info-card.client { border-left-color: #28a745; }
.info-card.pro { border-left-color: #6f42c1; }
.info-card.pricing { border-left-color: #ffc107; }

/* ═══════════════════════════════════ */
/* VERIFICATION BADGES                */
/* ═══════════════════════════════════ */

.verification-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    margin: 2px;
    font-weight: 500;
}
.verification-badge.approved {
    background-color: rgba(40, 167, 69, 0.2);
    color: #75d89a;
    border: 1px solid rgba(40, 167, 69, 0.3);
}
.verification-badge.pending {
    background-color: rgba(255, 193, 7, 0.15);
    color: #f0d262;
    border: 1px solid rgba(255, 193, 7, 0.3);
}
.verification-badge.rejected {
    background-color: rgba(220, 53, 69, 0.15);
    color: #e88a93;
    border: 1px solid rgba(220, 53, 69, 0.3);
}

/* ═══════════════════════════════════ */
/* LOGIN PAGE                         */
/* ═══════════════════════════════════ */

.login-page {
    background: linear-gradient(135deg, #1a1d21 0%, #2c3038 50%, #1a1d21 100%);
}
.login-box {
    width: 420px;
    max-width: calc(100vw - 1rem);
}
.login-card-body {
    border-radius: 12px;
    padding: 35px;
    background-color: #212529;
    border: 1px solid #2c3038;
}
.dark-mode .login-card-body .form-control {
    background-color: #2c3038;
    border-color: #3a3f47;
    color: #e0e0e0;
}
.login-page .card {
    border: 1px solid #2c3038;
    box-shadow: 0 8px 40px rgba(0,0,0,0.5);
}

/* ═══════════════════════════════════ */
/* ADMIN INFORMATION SYSTEM           */
/* ═══════════════════════════════════ */

:root {
    --admin-bg: #0d1117;
    --admin-surface: #151b23;
    --admin-surface-2: #1b2430;
    --admin-border: rgba(255,255,255,.075);
    --admin-text: #eef3f8;
    --admin-muted: #91a0af;
    --admin-blue: #38bdf8;
    --admin-green: #22c55e;
    --admin-amber: #f59e0b;
    --admin-red: #ef4444;
}

body {
    font-family: "Source Sans Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--admin-text);
}

.dark-mode .content-wrapper {
    background:
        radial-gradient(circle at 82% -10%, rgba(56,189,248,.07), transparent 28rem),
        var(--admin-bg);
}

.content-header {
    padding: 1.25rem 1rem .75rem;
}

.content-header h1 {
    font-size: 1.55rem;
    font-weight: 700;
    letter-spacing: -.025em;
}

.dark-mode .card {
    background: var(--admin-surface);
    border: 1px solid var(--admin-border);
    border-radius: 12px;
    box-shadow: 0 12px 30px rgba(0,0,0,.16);
    overflow: hidden;
}

.dark-mode .card-header {
    background: rgba(255,255,255,.012);
    padding: .9rem 1rem;
}

.card-title {
    font-weight: 650;
    letter-spacing: -.01em;
}

.dark-mode .table thead th {
    background: rgba(255,255,255,.018);
    border-bottom: 1px solid var(--admin-border);
}

.dark-mode .table td {
    vertical-align: middle;
}

.btn {
    border-radius: 7px;
    font-weight: 600;
}

.form-control {
    border-radius: 7px;
}

.main-sidebar {
    background: #10161e;
}

.brand-link {
    height: 58px;
    display: flex;
    align-items: center;
    background: rgba(0,0,0,.14);
    border-color: var(--admin-border) !important;
}

.brand-link .brand-text {
    letter-spacing: -.02em;
}

.nav-sidebar .nav-header {
    padding: 1.2rem 1rem .35rem;
    color: #657586;
    font-size: .67rem;
    font-weight: 800;
    letter-spacing: .13em;
}

.nav-sidebar .nav-link {
    margin: 2px 8px;
    width: auto;
    border-radius: 8px;
    color: #aeb9c5;
}

.nav-sidebar .nav-link p {
    font-weight: 550;
}

.nav-sidebar .nav-link.active {
    color: #fff !important;
    background: linear-gradient(135deg, #0f6f9c, #135d82) !important;
    box-shadow: 0 7px 18px rgba(2,132,199,.2) !important;
}

.nav-treeview .nav-link {
    font-size: .93rem;
}

.main-header {
    min-height: 58px;
}

.admin-navbar {
    flex-wrap: nowrap;
}

.admin-global-search {
    position: relative;
    flex: 1;
    min-width: 8rem;
    max-width: 520px;
}

.global-search-results {
    display: none;
    position: absolute;
    z-index: 1050;
    top: 100%;
    right: 0;
    left: 0;
    max-height: 380px;
    margin-top: 2px;
    overflow-y: auto;
    border: 1px solid #555;
    border-radius: 7px;
    background: #202832;
    box-shadow: 0 12px 28px rgba(0,0,0,.38);
}

.admin-page-intro {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 1.35rem 1.5rem;
    margin-bottom: 1rem;
    border: 1px solid rgba(56,189,248,.16);
    border-radius: 14px;
    background:
        linear-gradient(110deg, rgba(56,189,248,.10), rgba(34,197,94,.035)),
        var(--admin-surface);
}

.admin-page-intro h2 {
    margin: .15rem 0 .2rem;
    font-size: 1.45rem;
    font-weight: 700;
    letter-spacing: -.025em;
}

.admin-page-intro p {
    max-width: 850px;
    margin: 0;
    color: var(--admin-muted);
    line-height: 1.45;
}

.eyebrow {
    color: var(--admin-blue);
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .14em;
}

.metric-card {
    min-height: 132px;
    margin-bottom: 1rem;
    padding: 1rem 1.1rem;
    border: 1px solid var(--admin-border);
    border-left: 4px solid #64748b;
    border-radius: 11px;
    background: var(--admin-surface);
    box-shadow: 0 10px 24px rgba(0,0,0,.14);
}

.metric-card-success { border-left-color: var(--admin-green); }
.metric-card-warning { border-left-color: var(--admin-amber); }
.metric-card-primary { border-left-color: var(--admin-blue); }
.metric-card-danger { border-left-color: var(--admin-red); }
.metric-card-muted { border-left-color: #64748b; }

.metric-label {
    color: var(--admin-muted);
    font-size: .76rem;
    font-weight: 750;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.metric-value {
    margin: .25rem 0 .05rem;
    font-size: 2rem;
    font-weight: 750;
    letter-spacing: -.04em;
}

.metric-note {
    color: var(--admin-muted);
    font-size: .82rem;
}

.truth-stat {
    padding: .7rem 1rem;
    border-right: 1px solid var(--admin-border);
}

.truth-stat:last-child {
    border-right: 0;
}

.truth-stat span,
.truth-stat strong {
    display: block;
}

.truth-stat span {
    color: var(--admin-muted);
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .045em;
    text-transform: uppercase;
}

.truth-stat strong {
    margin-top: .15rem;
    font-size: 1.25rem;
}

.data-confidence {
    padding: .65rem .8rem;
    border: 1px solid var(--admin-border);
    border-radius: 8px;
    color: var(--admin-muted);
    background: rgba(255,255,255,.018);
}

.data-confidence.is-good {
    color: #86efac;
    border-color: rgba(34,197,94,.24);
    background: rgba(34,197,94,.06);
}

.data-confidence.is-warning {
    color: #fcd34d;
    border-color: rgba(245,158,11,.25);
    background: rgba(245,158,11,.06);
}

.global-search-heading {
    padding: 8px 11px 5px;
    color: #718096;
    font-size: .65rem;
    font-weight: 800;
    letter-spacing: .12em;
    background: #161d26;
}

.global-search-result {
    display: flex;
    align-items: center;
    padding: 9px 11px;
    border-bottom: 1px solid var(--admin-border);
    color: #e8edf2;
    text-decoration: none;
}

.global-search-result:hover {
    color: #fff;
    text-decoration: none;
    background: #303a46;
}

.global-search-result > span:last-child {
    min-width: 0;
}

.global-search-result strong,
.global-search-result small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.global-search-result small {
    color: #8e9aa7;
}

.global-search-icon {
    width: 36px;
    margin-right: 10px;
    color: var(--admin-blue);
    text-align: center;
}

@media (max-width: 767px) {
    .content-wrapper > .content {
        padding: 0 .5rem;
    }
    .content-header {
        padding: .8rem .5rem .4rem;
    }
    .admin-page-intro {
        align-items: flex-start;
        flex-direction: column;
        padding: 1rem;
    }
    .admin-page-intro > div,
    .admin-page-intro > div:last-child {
        width: 100%;
    }
    .admin-page-intro > div:last-child .btn {
        width: 100%;
        margin: .2rem 0;
    }
    .truth-stat {
        border-right: 0;
        border-bottom: 1px solid var(--admin-border);
    }
    .content-header h1 {
        font-size: 1.3rem;
    }
    .content-header .breadcrumb {
        display: none;
    }
    .admin-navbar .navbar-nav {
        flex-shrink: 0;
    }
    .admin-global-search {
        min-width: 0;
        max-width: none;
        margin-left: .35rem !important;
    }
    .admin-user-identity,
    .admin-logout-label {
        display: none;
    }
    .admin-navbar .nav-link {
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .global-search-results {
        position: fixed;
        top: 56px;
        right: .5rem;
        left: .5rem;
        max-height: min(65vh, 430px);
    }
    .dark-mode .card {
        border-radius: 10px;
    }
    .card-body {
        padding: .85rem;
    }
    .metric-card {
        min-height: 112px;
        padding: .85rem .9rem;
    }
    .metric-value {
        font-size: 1.7rem;
    }
    .nav-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        scrollbar-width: thin;
        -webkit-overflow-scrolling: touch;
    }
    .nav-tabs .nav-item {
        flex: 0 0 auto;
    }
    .nav-tabs .nav-link {
        min-height: 44px;
        white-space: nowrap;
    }
    .table-responsive {
        border-radius: 8px;
        -webkit-overflow-scrolling: touch;
    }
    .admin-mobile-table {
        width: 100% !important;
        min-width: 0 !important;
        margin: 0;
    }
    .admin-mobile-table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }
    .admin-mobile-table tbody,
    .admin-mobile-table tr,
    .admin-mobile-table td {
        display: block;
        width: 100%;
    }
    .admin-mobile-table tbody tr {
        margin: .7rem;
        width: calc(100% - 1.4rem);
        overflow: hidden;
        border: 1px solid var(--admin-border);
        border-radius: 9px;
        background: rgba(255,255,255,.018);
    }
    .admin-mobile-table tbody tr:hover {
        background: rgba(255,255,255,.035);
    }
    .admin-mobile-table td {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: .9rem;
        min-height: 42px;
        padding: .65rem .75rem;
        text-align: right !important;
        overflow-wrap: anywhere;
        border-top: 1px solid var(--admin-border) !important;
    }
    .admin-mobile-table td:first-child {
        border-top: 0 !important;
    }
    .admin-mobile-table td::before {
        content: attr(data-label);
        flex: 0 0 38%;
        color: var(--admin-muted);
        font-size: .7rem;
        font-weight: 750;
        letter-spacing: .045em;
        text-align: left;
        text-transform: uppercase;
    }
    .admin-mobile-table .admin-mobile-value {
        flex: 1 1 auto;
        min-width: 0;
        text-align: right;
    }
    .admin-mobile-table .admin-mobile-value > :last-child {
        margin-bottom: 0;
    }
    .admin-mobile-table td[data-label="Actions"] {
        align-items: center;
        flex-wrap: wrap;
    }
    .admin-mobile-table td[data-label="Actions"]::before {
        align-self: flex-start;
    }
    .admin-mobile-table td[data-label="Actions"] .admin-mobile-value {
        display: flex;
        align-items: center;
        justify-content: flex-end;
        flex-wrap: wrap;
        gap: .35rem;
    }
    .admin-mobile-table .admin-mobile-empty {
        margin: .7rem;
    }
    .admin-mobile-table .admin-mobile-empty td {
        display: block;
        padding: 1.5rem .75rem;
        text-align: center !important;
    }
    .admin-mobile-table .admin-mobile-empty td::before {
        display: none;
    }
    .coverage-card .admin-mobile-table {
        min-width: 0 !important;
    }
    .card-header.d-flex,
    .card-footer.d-flex,
    .modal-footer {
        align-items: stretch !important;
        flex-wrap: wrap;
        gap: .45rem;
    }
    .card-header.d-flex > .card-title {
        width: 100%;
        margin-bottom: .25rem;
    }
    .card-header.d-flex > .btn,
    .card-header.d-flex > a.btn,
    .modal-footer .btn {
        flex: 1 1 auto;
        margin: 0 !important;
    }
    .btn-group {
        display: flex;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .btn-group > .btn {
        flex: 1 0 auto;
        white-space: nowrap;
    }
    .chat-messages {
        height: min(58vh, 500px) !important;
        min-height: 280px;
        padding: .75rem !important;
    }
    .chat-input-area .input-group {
        align-items: stretch;
        flex-wrap: wrap;
        gap: .4rem;
    }
    .chat-input-area .input-group > .form-control {
        flex: 1 1 calc(100% - 3.5rem);
        width: auto;
    }
    .chat-input-area .input-group-append {
        margin-left: 0;
    }
    .btn:not(.close),
    .page-link {
        min-height: 40px;
    }
    .btn-xs {
        min-height: 36px !important;
        padding: .35rem .6rem;
        font-size: .8rem;
    }
    .modal-dialog {
        margin: .5rem;
    }
    .modal-content {
        border-radius: 10px;
    }
    .chat-message {
        max-width: 90%;
    }
    .main-footer {
        padding: .75rem;
        font-size: .82rem;
    }
    .pagination {
        flex-wrap: wrap;
        gap: .2rem;
    }
}

.admin-form-submitting {
    pointer-events: none;
    opacity: .72;
}

.admin-form-submitting button[type="submit"] {
    cursor: wait;
}

/* ═══════════════════════════════════ */
/* TAB NAV                            */
/* ═══════════════════════════════════ */

.nav-tabs .nav-link.active {
    font-weight: 600;
}
.tab-count {
    background-color: #dc3545;
    color: white;
    border-radius: 50%;
    padding: 1px 6px;
    font-size: 0.7rem;
    margin-left: 5px;
}

/* ═══════════════════════════════════ */
/* TIMELINE                           */
/* ═══════════════════════════════════ */

.timeline-item {
    border-left: 2px solid #2c3038;
    padding: 10px 20px;
    position: relative;
}
.timeline-item::before {
    content: '';
    width: 12px;
    height: 12px;
    background: #007bff;
    border-radius: 50%;
    position: absolute;
    left: -7px;
    top: 15px;
}

/* ═══════════════════════════════════ */
/* BUTTONS                            */
/* ═══════════════════════════════════ */

.btn-action {
    margin: 2px;
}
.btn-outline-primary:hover,
.btn-outline-info:hover,
.btn-outline-success:hover {
    color: #fff;
}

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

@media (max-width: 768px) {
    .small-box .inner h3 {
        font-size: 1.5rem;
    }
}
