﻿/* ============================================================
   License Hub – Admin CSS
   Supplements Bootstrap 5. Only custom components that
   Bootstrap does not provide natively are defined here.
   ============================================================ */

/* ---- Sidebar ------------------------------------------------------------ */
.hub-wrapper {
    min-height: calc(100vh - 57px);
    position: relative;
}

.hub-sidebar {
    width: 240px;
    min-width: 240px;
    position: sticky;
    top: 57px;
    height: calc(100vh - 57px);
    overflow-y: auto;
    transition: width 0.2s ease, min-width 0.2s ease;
    z-index: 100;
}

.hub-sidebar.collapsed {
    width: 68px;
    min-width: 68px;
}

.hub-main {
    min-width: 0;
}

.hub-sidebar-backdrop {
    position: fixed;
    inset: 57px 0 0 0;
    background: rgba(15, 23, 42, 0.45);
    border: 0;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    z-index: 99;
}

.hub-sidebar-backdrop.show {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Sidebar nav items */
.hub-sidenav .list-group-item {
    border: none;
    border-radius: 0 !important;
    padding: 0.75rem 1.25rem;
    font-weight: 500;
    font-size: 0.875rem;
    color: #495057;
    border-left: 3px solid transparent;
    display: flex;
    align-items: center;
    gap: 0;
    transition: background 0.15s, color 0.15s, border-left-color 0.15s;
    text-decoration: none;
}

[dir="rtl"] .hub-sidenav .list-group-item {
    border-left: none;
    border-right: 3px solid transparent;
}

.hub-sidenav .list-group-item:hover,
.hub-sidenav .list-group-item.active {
    color: #0d6efd;
    background-color: #f0f7ff;
    border-left-color: #0d6efd;
}

[dir="rtl"] .hub-sidenav .list-group-item:hover,
[dir="rtl"] .hub-sidenav .list-group-item.active {
    border-left: none;
    border-right: 3px solid #0d6efd;
}

.hub-sidenav .list-group-item i {
    width: 22px;
    text-align: center;
    font-size: 1rem;
    color: #adb5bd;
    flex-shrink: 0;
}

.hub-sidenav .list-group-item:hover i,
.hub-sidenav .list-group-item.active i {
    color: #0d6efd;
}

.hub-sidenav .nav-label {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Collapsed sidebar: hide labels */
.hub-sidebar.collapsed .hub-sidenav .list-group-item {
    justify-content: center;
    padding: 0.75rem 0;
}

.hub-sidebar.collapsed .hub-sidenav .nav-label,
.hub-sidebar.collapsed .hub-sidenav .badge {
    display: none;
}

.hub-sidebar.collapsed .hub-sidenav .list-group-item i {
    width: auto;
}

/* Brand dot in navbar */
.hub-brand-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #22d3ee);
    vertical-align: middle;
    margin-inline-end: 4px;
}

.hub-brand-text {
    max-width: min(40vw, 320px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---- Stat cards --------------------------------------------------------- */
.stat-card {
    border-left: 4px solid #0d6efd;
    transition: box-shadow 0.2s;
}

[dir="rtl"] .stat-card {
    border-left: none;
    border-right: 4px solid #0d6efd;
}

.stat-card:hover {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.09) !important;
}

.stat-card.color-success { border-color: #198754; }
.stat-card.color-warning { border-color: #ffc107; }
.stat-card.color-danger  { border-color: #dc3545; }
.stat-card.color-info    { border-color: #0dcaf0; }
.stat-card.color-secondary { border-color: #6c757d; }

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.1;
}

.stat-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6c757d;
}

/* ---- Hub list (recent items in cards) ----------------------------------- */
.hub-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: 13px;
}

.hub-list-item:last-child {
    border-bottom: none;
}

/* ---- Chart container ---------------------------------------------------- */
.chart-wrap {
    position: relative;
    height: 220px;
}

/* ---- Utility ------------------------------------------------------------ */
.mono {
    font-family: Consolas, 'Courier New', monospace;
}

/* ---- Login page --------------------------------------------------------- */
.hub-login-bg {
    min-height: 100vh;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* ---- Clients page -------------------------------------------------------- */
.hub-clients-hero {
    position: relative;
    overflow: hidden;
    background:
        radial-gradient(1200px 260px at 8% -35%, rgba(255, 255, 255, 0.25) 0%, rgba(255, 255, 255, 0) 68%),
        radial-gradient(700px 220px at 100% 10%, rgba(16, 185, 129, 0.2) 0%, rgba(16, 185, 129, 0) 72%),
        linear-gradient(130deg, #0f3b82 0%, #0d6efd 56%, #0891b2 100%);
    color: #f8fafc;
}

.hub-clients-hero-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
    gap: 1rem;
    align-items: center;
}

.hub-clients-eyebrow {
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(248, 250, 252, 0.85);
    margin-bottom: 0.35rem;
}

.hub-clients-hero-copy {
    max-width: 68ch;
    color: rgba(241, 245, 249, 0.92);
}

.hub-clients-hero-meta {
    font-size: 0.84rem;
    color: rgba(226, 232, 240, 0.95);
}

.hub-clients-hero-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.hub-clients-search-form .input-group {
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 12px 26px rgba(2, 6, 23, 0.2);
}

.hub-clients-search-form .input-group-text {
    border: none;
    background: #eff6ff;
    color: #1d4ed8;
}

.hub-clients-search-form .form-control,
.hub-clients-search-form .btn {
    border: none;
}

.hub-clients-add-btn {
    width: 100%;
    border: 0;
    font-weight: 600;
    box-shadow: 0 10px 20px rgba(245, 158, 11, 0.3);
}

.hub-clients-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
    gap: 0.75rem;
}

.hub-clients-kpi-card {
    border-radius: 14px;
    border: 1px solid #e2e8f0;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    padding: 0.85rem 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.hub-clients-kpi-icon {
    width: 2.15rem;
    height: 2.15rem;
    border-radius: 0.7rem;
    background: #e0f2fe;
    color: #0c4a6e;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.hub-clients-kpi-label {
    font-size: 0.74rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.hub-clients-kpi-value {
    font-size: 1.35rem;
    line-height: 1.1;
    font-weight: 700;
    color: #0f172a;
}

.hub-clients-filter-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
}

.hub-filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    border: 1px solid #dbe4f3;
    border-radius: 999px;
    color: #334155;
    text-decoration: none;
    padding: 0.38rem 0.72rem;
    font-size: 0.82rem;
    font-weight: 500;
    background: #f8fafc;
    transition: all 0.18s ease;
}

.hub-filter-chip:hover {
    border-color: #93c5fd;
    background: #eff6ff;
    color: #1e3a8a;
}

.hub-filter-chip.is-active {
    border-color: #2563eb;
    background: #2563eb;
    color: #ffffff;
}

.hub-filter-chip-count {
    min-width: 1.3rem;
    height: 1.3rem;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(37, 99, 235, 0.12);
    color: #1e3a8a;
    font-size: 0.72rem;
    font-weight: 700;
}

.hub-filter-chip.is-active .hub-filter-chip-count {
    background: rgba(255, 255, 255, 0.22);
    color: #ffffff;
}

.hub-clients-table-card {
    border-radius: 16px;
    overflow: hidden;
}

.hub-clients-table thead th {
    background: #f1f5f9;
    border-bottom: 1px solid #dbeafe;
    font-size: 0.77rem;
    text-transform: uppercase;
    letter-spacing: 0.045em;
    color: #475569;
    white-space: nowrap;
}

.hub-clients-table tbody td {
    border-color: #eef2f7;
    vertical-align: middle;
}

.hub-clients-table tbody tr:hover {
    background: #f8fbff;
}

.hub-client-mobile-list {
    display: grid;
    gap: 0.75rem;
}

.hub-client-mobile-card {
    border-radius: 14px;
    overflow: hidden;
}

.hub-client-mobile-meta {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.45rem 0.8rem;
}

.hub-client-mobile-meta span {
    display: block;
    font-size: 0.73rem;
    color: #64748b;
    margin-bottom: 0.1rem;
}

.hub-client-mobile-meta strong {
    display: block;
    font-size: 0.83rem;
    color: #0f172a;
    font-weight: 600;
    line-height: 1.25;
}

.hub-client-mobile-action-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

[dir="rtl"] .hub-clients-kpi-card,
[dir="rtl"] .hub-filter-chip {
    direction: rtl;
}

/* ---- Responsive --------------------------------------------------------- */
@media (max-width: 991.98px) {
    .hub-wrapper {
        min-height: calc(100vh - 57px);
    }

    .hub-sidebar {
        position: fixed;
        top: 57px;
        bottom: 0;
        left: 0;
        height: auto;
        width: min(84vw, 300px);
        min-width: min(84vw, 300px);
        z-index: 101;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
    }

    [dir="rtl"] .hub-sidebar {
        left: auto;
        right: 0;
        transform: translateX(100%);
    }

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

    .hub-sidebar.collapsed {
        width: min(84vw, 300px);
        min-width: min(84vw, 300px);
    }

    .hub-sidebar.collapsed .hub-sidenav .list-group-item {
        justify-content: flex-start;
        padding: 0.75rem 1rem;
    }

    .hub-sidebar.collapsed .hub-sidenav .nav-label,
    .hub-sidebar.collapsed .hub-sidenav .badge {
        display: inline;
    }

    .hub-main .container-fluid {
        padding-left: 0.9rem !important;
        padding-right: 0.9rem !important;
    }

    .hub-topbar-actions .dropdown .btn {
        max-width: 120px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .hub-filter .col-auto {
        width: 100%;
    }

    .hub-filter .form-control,
    .hub-filter .form-select,
    .hub-filter .btn {
        width: 100%;
    }

    .hub-search-form {
        width: 100%;
    }

    .hub-search-form .form-control,
    .hub-search-form .btn {
        width: 100%;
    }

    .hub-clients-hero-grid {
        grid-template-columns: 1fr;
    }

    .hub-clients-hero-actions {
        width: 100%;
    }

    .hub-clients-filter-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 0.15rem;
    }

    .hub-filter-chip {
        white-space: nowrap;
        flex-shrink: 0;
    }
}

@media (max-width: 575.98px) {
    .hub-brand-text {
        max-width: 42vw;
        font-size: 1rem;
    }

    .hub-topbar-actions {
        gap: 0.35rem !important;
    }

    .hub-topbar-actions .btn {
        padding-left: 0.45rem;
        padding-right: 0.45rem;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    .chart-wrap {
        height: 200px;
    }

    .hub-clients-kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .hub-client-mobile-action-grid {
        grid-template-columns: 1fr;
    }

    .hub-client-mobile-meta {
        grid-template-columns: 1fr;
    }
}

body.hub-no-scroll {
    overflow: hidden;
}

/* Ensure long add/edit modal forms always scroll smoothly */
#clientModal .modal-dialog,
#userModal .modal-dialog {
    margin-top: 1rem;
    margin-bottom: 1rem;
}

#clientModal .modal-content,
#userModal .modal-content {
    max-height: calc(100vh - 2rem);
}

#clientModal .modal-body,
#userModal .modal-body {
    max-height: calc(100vh - 11rem);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 767.98px) {
    #clientModal .modal-dialog,
    #userModal .modal-dialog {
        margin: 0.5rem;
    }

    #clientModal .modal-content,
    #userModal .modal-content {
        max-height: calc(100vh - 1rem);
    }

    #clientModal .modal-body,
    #userModal .modal-body {
        max-height: calc(100vh - 9.5rem);
    }
}