/* DMS v2 – Application Stylesheet (Bootstrap 5.3 companion) */

/* ── CSS Custom Properties ──────────────────────────────────────── */
:root {
    --dms-sidebar-width: 260px;
    --dms-sidebar-bg: #1e2a38;
    --dms-sidebar-text: #c8d3de;
    --dms-sidebar-hover: #2d3f52;
    --dms-sidebar-active: #0d6efd;
    --dms-topbar-height: 56px;
    --dms-body-bg: #f4f6f9;
    --dms-card-radius: 0.5rem;
    --dms-transition: 0.2s ease;
}

/* ── Base ────────────────────────────────────────────────────────── */
body {
    background-color: var(--dms-body-bg);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 0.9rem;
}

/* ── Layout ──────────────────────────────────────────────────────── */
.dms-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────────────── */
#sidebar {
    width: var(--dms-sidebar-width);
    min-height: 100vh;
    background: var(--dms-sidebar-bg);
    color: var(--dms-sidebar-text);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    transition: transform var(--dms-transition);
    z-index: 100;
}

#sidebar .sidebar-brand {
    padding: 1.25rem 1.5rem;
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,0.07);
    text-decoration: none;
    display: block;
}

#sidebar .sidebar-brand span {
    color: var(--dms-sidebar-active);
}

#sidebar .nav-label {
    padding: 0.75rem 1.5rem 0.25rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255,255,255,0.35);
    font-weight: 600;
}

#sidebar .nav-link {
    color: var(--dms-sidebar-text);
    padding: 0.55rem 1.5rem;
    border-radius: 0;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    transition: background var(--dms-transition), color var(--dms-transition);
    font-size: 0.875rem;
}

#sidebar .nav-link:hover,
#sidebar .nav-link:focus {
    background: var(--dms-sidebar-hover);
    color: #fff;
}

#sidebar .nav-link.active {
    background: var(--dms-sidebar-active);
    color: #fff;
}

#sidebar .nav-link i,
#sidebar .nav-link svg {
    width: 1.1rem;
    opacity: 0.8;
}

/* ── Main Content ────────────────────────────────────────────────── */
.dms-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* ── Topbar ──────────────────────────────────────────────────────── */
.dms-topbar {
    height: var(--dms-topbar-height);
    background: #fff;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    gap: 0.75rem;
    position: sticky;
    top: 0;
    z-index: 99;
}

.dms-topbar .topbar-search {
    position: relative;
    flex: 1;
    max-width: 380px;
}

.dms-topbar .topbar-search input {
    padding-left: 2.25rem;
    background: var(--dms-body-bg);
    border-color: transparent;
}

.dms-topbar .topbar-search .search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: #adb5bd;
    pointer-events: none;
}

/* Search dropdown */
#searchResults {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: var(--dms-card-radius);
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
    max-height: 320px;
    overflow-y: auto;
    z-index: 200;
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0.875rem;
    text-decoration: none;
    color: inherit;
    transition: background var(--dms-transition);
}

.search-result-item:hover {
    background: var(--dms-body-bg);
}

.search-result-type {
    font-size: 0.68rem;
    background: #e9ecef;
    color: #495057;
    padding: 0.15rem 0.4rem;
    border-radius: 0.25rem;
    flex-shrink: 0;
}

.search-result-label {
    flex: 1;
    font-size: 0.875rem;
}

.search-result-sub {
    font-size: 0.78rem;
}

.search-no-results {
    padding: 1rem;
    text-align: center;
    color: #6c757d;
    font-size: 0.85rem;
}

/* ── Page content ────────────────────────────────────────────────── */
.dms-content {
    padding: 1.5rem;
    flex: 1;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.page-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
    color: #212529;
}

/* ── Cards ───────────────────────────────────────────────────────── */
.card {
    border: 1px solid #e9ecef;
    border-radius: var(--dms-card-radius);
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.card-header {
    background: #fff;
    border-bottom: 1px solid #e9ecef;
    font-weight: 600;
    font-size: 0.875rem;
    padding: 0.875rem 1.25rem;
}

/* ── Stat cards ──────────────────────────────────────────────────── */
.stat-card {
    background: #fff;
    border-radius: var(--dms-card-radius);
    border: 1px solid #e9ecef;
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.stat-card .stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1;
    color: #212529;
}

.stat-card .stat-label {
    font-size: 0.8rem;
    color: #6c757d;
    margin-top: 0.2rem;
}

/* ── Tables ──────────────────────────────────────────────────────── */
.table-responsive {
    border-radius: var(--dms-card-radius);
}

.table thead th {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6c757d;
    font-weight: 600;
    border-bottom: 2px solid #e9ecef;
    white-space: nowrap;
}

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

/* ── Badges ──────────────────────────────────────────────────────── */
.badge-status {
    padding: 0.3rem 0.6rem;
    border-radius: 0.3rem;
    font-size: 0.75rem;
    font-weight: 500;
}

/* ── Forms ───────────────────────────────────────────────────────── */
.form-label {
    font-weight: 500;
    font-size: 0.875rem;
    margin-bottom: 0.35rem;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--dms-sidebar-active);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.15);
}

/* ── Pagination ──────────────────────────────────────────────────── */
.pagination .page-link {
    font-size: 0.875rem;
}

/* ── Portal layouts (client, partner, agent) ─────────────────────── */
.portal-wrapper {
    min-height: 100vh;
    background: var(--dms-body-bg);
}

.portal-navbar {
    background: var(--dms-sidebar-bg);
    padding: 0.75rem 1.25rem;
}

.portal-navbar .navbar-brand {
    color: #fff;
    font-weight: 700;
}

.portal-navbar .nav-link {
    color: var(--dms-sidebar-text);
    padding: 0.5rem 0.875rem;
    border-radius: 0.375rem;
    transition: background var(--dms-transition), color var(--dms-transition);
}

.portal-navbar .nav-link:hover,
.portal-navbar .nav-link.active {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

.portal-content {
    padding: 1.5rem;
}

/* ── Auth pages ──────────────────────────────────────────────────── */
.auth-wrapper {
    min-height: 100vh;
    background: linear-gradient(135deg, var(--dms-sidebar-bg) 0%, #2d3f52 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-card {
    background: #fff;
    border-radius: 0.75rem;
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.auth-logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--dms-sidebar-bg);
    margin-bottom: 0.25rem;
}

/* ── Utility ─────────────────────────────────────────────────────── */
.cursor-pointer { cursor: pointer; }
.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ── Notification badge ──────────────────────────────────────────── */
.notif-badge-wrapper {
    position: relative;
    display: inline-flex;
}

#notifBadge {
    position: absolute;
    top: -6px;
    right: -8px;
    min-width: 18px;
    height: 18px;
    font-size: 0.65rem;
    padding: 0 0.3rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 9px;
}

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 992px) {
    #sidebar {
        position: fixed;
        transform: translateX(-100%);
        top: 0;
        left: 0;
        height: 100%;
    }

    #sidebar.show {
        transform: translateX(0);
    }

    .dms-main {
        width: 100%;
    }
}

@media (max-width: 576px) {
    .dms-content {
        padding: 1rem;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }
}
