/* ==========================================================================
   Makkah Cold Storage - shared theme
   Used by Site.master (admin pages), Login.aspx and Main.aspx
   ========================================================================== */

:root {
    --cs-navy: #0a1f33;
    --cs-navy-2: #123a5c;
    --cs-ice: #7dd3fc;
    --cs-blue: #0ea5e9;
    --cs-blue-dark: #0369a1;
    --cs-frost: #e6f4fb;
    --cs-bg: #eef5fa;
    --cs-text: #0f2a40;
    --cs-muted: #5f7689;
    --cs-border: #d6e5ef;
    --cs-success: #10b981;
    --cs-danger: #ef4444;
    --cs-warning: #f59e0b;
    --cs-radius: 16px;
    --cs-shadow: 0 6px 24px rgba(10, 31, 51, 0.08);
    --cs-shadow-hover: 0 12px 32px rgba(10, 31, 51, 0.14);
    --cs-sidebar-w: 264px;
    --cs-sidebar-w-collapsed: 84px;
    --cs-topbar-h: 68px;
}

/* ---------- Base ---------- */
html {
    scroll-behavior: smooth;
}

body.app-body {
    font-family: 'Poppins', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--cs-bg);
    color: var(--cs-text);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ---------- Shell layout ---------- */
.app-shell {
    min-height: 100vh;
}

.app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--cs-sidebar-w);
    z-index: 1040;
    display: flex;
    flex-direction: column;
    background:
        radial-gradient(circle at 20% 10%, rgba(125, 211, 252, 0.18), transparent 40%),
        radial-gradient(circle at 80% 90%, rgba(56, 189, 248, 0.12), transparent 45%),
        linear-gradient(180deg, var(--cs-navy) 0%, var(--cs-navy-2) 100%);
    color: #e6f4fb;
    box-shadow: 4px 0 24px rgba(10, 31, 51, 0.18);
    transition: width 0.3s ease, transform 0.3s ease;
    overflow: hidden;
}

.app-sidebar::before {
    /* drifting frost dots */
    content: '';
    position: absolute;
    inset: -50%;
    background-image: radial-gradient(rgba(255, 255, 255, 0.10) 1.2px, transparent 1.4px);
    background-size: 26px 26px;
    animation: frostDrift 26s linear infinite;
    pointer-events: none;
}

@keyframes frostDrift {
    from { transform: translate(0, 0); }
    to { transform: translate(26px, 52px); }
}

.sidebar-brand {
    position: relative;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 22px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    min-height: var(--cs-topbar-h);
}

.brand-icon {
    flex: 0 0 44px;
    height: 44px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--cs-blue), var(--cs-ice));
    box-shadow: 0 6px 18px rgba(14, 165, 233, 0.45);
    font-size: 22px;
    color: #fff;
}

.brand-icon i {
    animation: spinSlow 14s linear infinite;
}

@keyframes spinSlow {
    to { transform: rotate(360deg); }
}

.brand-title {
    font-weight: 700;
    font-size: 15px;
    line-height: 1.2;
    white-space: nowrap;
}

.brand-sub {
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--cs-ice);
    opacity: 0.85;
}

.sidebar-nav {
    position: relative;
    flex: 1;
    overflow-y: auto;
    padding: 14px 12px;
}

.nav-section {
    font-size: 11px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: rgba(230, 244, 251, 0.5);
    padding: 16px 12px 6px;
    white-space: nowrap;
}

.sidebar-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 11px 14px;
    margin: 3px 0;
    border-radius: 12px;
    color: #cfe6f3;
    text-decoration: none;
    font-size: 14.5px;
    font-weight: 500;
    white-space: nowrap;
    transition: background 0.2s ease, color 0.2s ease, padding-left 0.2s ease;
}

.sidebar-link i {
    width: 22px;
    text-align: center;
    font-size: 16px;
    flex: 0 0 22px;
    transition: transform 0.25s ease;
}

.sidebar-link:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    padding-left: 18px;
}

.sidebar-link:hover i {
    transform: scale(1.15);
}

.sidebar-link.active {
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.35), rgba(125, 211, 252, 0.15));
    color: #fff;
    box-shadow: inset 0 0 0 1px rgba(125, 211, 252, 0.25);
}

.sidebar-link.active::before {
    content: '';
    position: absolute;
    left: -12px;
    top: 10px;
    bottom: 10px;
    width: 4px;
    border-radius: 0 4px 4px 0;
    background: var(--cs-ice);
    box-shadow: 0 0 12px var(--cs-ice);
}

.sidebar-footer {
    position: relative;
    padding: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* "Install app" button (PWA) looks like a sidebar link */
.pwa-install-btn {
    width: 100%;
    border: 0;
    background: transparent;
    text-align: left;
    font-family: inherit;
    cursor: pointer;
    color: #7dd3fc;
}

.pwa-install-btn[hidden] {
    display: none !important;
}

.sidebar-link.logout {
    color: #fca5a5;
}

.sidebar-link.logout:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #fff;
}

/* Desktop collapsed (icons only) */
body.sidebar-collapsed .app-sidebar {
    width: var(--cs-sidebar-w-collapsed);
}

body.sidebar-collapsed .app-main {
    margin-left: var(--cs-sidebar-w-collapsed);
}

body.sidebar-collapsed .brand-title,
body.sidebar-collapsed .brand-sub,
body.sidebar-collapsed .sidebar-link span,
body.sidebar-collapsed .nav-section {
    display: none;
}

body.sidebar-collapsed .sidebar-link {
    justify-content: center;
    padding: 12px 0;
}

body.sidebar-collapsed .sidebar-link:hover {
    padding-left: 0;
}

body.sidebar-collapsed .sidebar-link.active::before {
    left: -12px;
}

.app-main {
    margin-left: var(--cs-sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s ease;
    min-width: 0;
}

.app-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(10, 31, 51, 0.45);
    backdrop-filter: blur(2px);
    z-index: 1035;
}

/* ---------- Top bar ---------- */
.app-topbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    height: var(--cs-topbar-h);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 28px;
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--cs-border);
    box-shadow: 0 2px 12px rgba(10, 31, 51, 0.04);
}

/* frost shimmer line along the bottom of the topbar */
.app-topbar::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--cs-ice), var(--cs-blue), transparent);
    background-size: 200% 100%;
    animation: shimmer 4s linear infinite;
    opacity: 0.8;
}

@keyframes shimmer {
    from { background-position: 200% 0; }
    to { background-position: -200% 0; }
}

.topbar-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--cs-navy);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    flex: 1;
}

.btn-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    border: 1px solid var(--cs-border);
    background: #fff;
    color: var(--cs-navy-2);
    display: grid;
    place-items: center;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    flex: 0 0 42px;
}

.btn-icon:hover {
    background: var(--cs-frost);
    color: var(--cs-blue-dark);
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 14px 6px 6px;
    border-radius: 999px;
    background: #fff;
    border: 1px solid var(--cs-border);
    font-weight: 500;
    font-size: 14px;
    white-space: nowrap;
}

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--cs-blue), var(--cs-ice));
    color: #fff;
    font-weight: 700;
    font-size: 14px;
}

/* ---------- Content area: full width ---------- */
.app-content {
    flex: 1;
    width: 100%;
    padding: 28px;
    min-width: 0;
}

/* Let every page use the full window width instead of Bootstrap's fixed containers */
.app-content .container,
.app-content .container-fluid,
.app-content .container-sm,
.app-content .container-md,
.app-content .container-lg,
.app-content .container-xl,
.app-content .container-xxl {
    max-width: 100% !important;
    width: 100%;
    padding-left: 0;
    padding-right: 0;
}

/* Older pages set their own full-page body gradient and fixed-width wrapper: neutralise them inside the app shell */
body.app-body {
    background: var(--cs-bg) !important;
    padding: 0 !important;
    margin: 0 !important;
    min-height: 100vh;
}

.app-content .container-custom {
    max-width: 100% !important;
    width: 100%;
    margin: 0 !important;
    padding: 0 !important;
}

/* Gentle entrance animation for page sections (no transform left behind, so modals keep working) */
.app-content > * {
    animation: csFadeUp 0.5s ease-out backwards;
}

.app-content > *:nth-child(2) { animation-delay: 0.05s; }
.app-content > *:nth-child(3) { animation-delay: 0.1s; }
.app-content > *:nth-child(4) { animation-delay: 0.15s; }

@keyframes csFadeUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

/* ---------- Cards ---------- */
.card {
    border: 1px solid var(--cs-border);
    border-radius: var(--cs-radius);
    box-shadow: var(--cs-shadow);
    background: #fff;
    transition: box-shadow 0.25s ease, border-color 0.25s ease;
}

.card:hover {
    box-shadow: var(--cs-shadow-hover);
}

.card-header {
    background: #fff;
    border-bottom: 1px solid var(--cs-border);
    font-weight: 600;
    border-radius: var(--cs-radius) var(--cs-radius) 0 0 !important;
}

/* ---------- Buttons ---------- */
.btn {
    border-radius: 12px;
    font-weight: 500;
    transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: linear-gradient(135deg, var(--cs-blue), var(--cs-blue-dark));
    border: none;
    box-shadow: 0 6px 16px rgba(14, 165, 233, 0.28);
}

.btn-primary:hover,
.btn-primary:focus {
    background: linear-gradient(135deg, var(--cs-blue-dark), var(--cs-navy-2));
    box-shadow: 0 10px 22px rgba(14, 165, 233, 0.38);
}

.btn-outline-primary {
    color: var(--cs-blue-dark);
    border-color: var(--cs-blue);
}

.btn-outline-primary:hover {
    background: var(--cs-blue);
    border-color: var(--cs-blue);
}

/* ---------- Forms ---------- */
.form-control,
.form-select {
    border-radius: 12px;
    border-color: var(--cs-border);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--cs-blue);
    box-shadow: 0 0 0 0.2rem rgba(14, 165, 233, 0.18);
}

.form-label {
    font-weight: 500;
    color: var(--cs-text);
}

/* ---------- Tables ---------- */
.table {
    --bs-table-bg: transparent;
}

.table thead th {
    background: var(--cs-frost);
    color: var(--cs-navy-2);
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--cs-border);
}

.table-hover > tbody > tr:hover > * {
    background-color: rgba(14, 165, 233, 0.06);
}

.table-responsive {
    border-radius: var(--cs-radius);
}

/* DataTables skin */
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
    border-radius: 10px;
    border: 1px solid var(--cs-border);
    padding: 6px 10px;
}

.dataTables_wrapper .dataTables_paginate .page-link {
    border-radius: 10px !important;
    margin: 0 2px;
    color: var(--cs-blue-dark);
}

.dataTables_wrapper .dataTables_paginate .page-item.active .page-link {
    background: linear-gradient(135deg, var(--cs-blue), var(--cs-blue-dark));
    border-color: transparent;
}

/* ---------- Modals ---------- */
.modal-content {
    border: none;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 24px 60px rgba(10, 31, 51, 0.25);
}

.modal-header {
    border-bottom: 1px solid var(--cs-border);
}

/* ---------- Alerts / badges ---------- */
.alert {
    border-radius: 14px;
    border: none;
}

.badge {
    border-radius: 999px;
    font-weight: 500;
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ---------- Tablet & phone: off-canvas sidebar ---------- */
@media (max-width: 991.98px) {
    .app-sidebar {
        transform: translateX(-100%);
        width: var(--cs-sidebar-w);
    }

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

    body.sidebar-open .app-overlay {
        display: block;
    }

    /* collapsed mode is a desktop-only feature */
    body.sidebar-collapsed .app-main {
        margin-left: 0;
    }

    body.sidebar-collapsed .app-sidebar {
        width: var(--cs-sidebar-w);
    }

    body.sidebar-collapsed .brand-title,
    body.sidebar-collapsed .brand-sub,
    body.sidebar-collapsed .sidebar-link span,
    body.sidebar-collapsed .nav-section {
        display: revert;
    }

    body.sidebar-collapsed .sidebar-link {
        justify-content: flex-start;
        padding: 11px 14px;
    }

    .app-main {
        margin-left: 0;
    }

    .app-topbar {
        padding: 0 16px;
        gap: 12px;
    }

    .app-content {
        padding: 20px 16px;
    }
}

@media (max-width: 575.98px) {
    :root {
        --cs-topbar-h: 60px;
    }

    .topbar-title {
        font-size: 16px;
    }

    .topbar-user span:not(.user-avatar) {
        display: none;
    }

    .topbar-user {
        padding: 4px;
    }

    .app-content {
        padding: 16px 12px;
    }

    .card {
        border-radius: 14px;
    }

    .btn {
        min-height: 44px;
    }
}

/* ==========================================================================
   Login & public pages helpers
   ========================================================================== */

.cs-snow-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.cs-glass {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(14px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: 0 24px 60px rgba(10, 31, 51, 0.22);
}
