@import url('https://fonts.googleapis.com/css2?family=Rubik:wght@400;500;600;700&display=swap');

:root {
    --primary: #0086A3;
    --primary-dark: #006f87;
    --secondary: #3A414E;
    --navy: #0C1E36;
    --accent: #0086A3;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --text-primary: #0C1E36;
    --text-secondary: #3A414E;
    --bg-primary: #ffffff;
    --bg-secondary: #f4f6f8;
    --bg-tertiary: #eaecef;
    --border: #d1d5db;
    --shadow-sm: 0 1px 2px 0 rgba(12, 30, 54, 0.06);
    --shadow: 0 4px 6px -1px rgba(12, 30, 54, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(12, 30, 54, 0.12);
    --shadow-xl: 0 20px 25px -5px rgba(12, 30, 54, 0.15);
}

[data-theme="dark"] {
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --bg-primary: #1e2533;
    --bg-secondary: #151b27;
    --bg-tertiary: #2a3347;
    --border: #334155;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.6);
}

/* ── Scrollbar styling ────────────────────────────────────────────────── */

/* Webkit / Blink (Chrome, Edge, Safari) */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
    border: 2px solid transparent;
    background-clip: padding-box;
}

::-webkit-scrollbar-corner {
    background: var(--bg-secondary);
}

/* Sidebar scrollbar — blends with the dark navy background */
.sidebar ::-webkit-scrollbar-track,
.nav-links::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar ::-webkit-scrollbar-thumb,
.nav-links::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border: 2px solid transparent;
    background-clip: padding-box;
}

.sidebar ::-webkit-scrollbar-thumb:hover,
.nav-links::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
    border: 2px solid transparent;
    background-clip: padding-box;
}

.nav-links {
    scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

/* ── Drag-and-drop zones ──────────────────────────────────────────────── */
.drop-zone {
    position: relative;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.drop-zone.drag-active {
    border-color: var(--primary) !important;
    background: rgba(0, 134, 163, 0.06) !important;
}

/* Invisible file input that covers the entire drop zone */
.drop-zone-input {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    opacity: 0 !important;
    cursor: pointer !important;
    font-size: 0 !important;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    scrollbar-width: thin;
    scrollbar-color: var(--border) var(--bg-secondary);
}

body {
    font-family: 'Rubik', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: var(--text-primary);
    background: var(--bg-secondary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

.page-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--navy);
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    box-shadow: var(--shadow-xl);
    z-index: 100;
}

.sidebar-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-logo {
    display: block;
    width: 100%;
    height: auto;
    max-height: 44px;
    object-fit: contain;
    object-position: left center;
}

.nav-links {
    flex: 1;
    padding: 1rem 0.75rem;
    overflow-y: auto;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.875rem;
    margin-bottom: 0.25rem;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    border-radius: 12px;
    transition: all 0.2s ease;
    font-weight: 500;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    transform: translateX(4px);
}

.nav-link.active {
    background: var(--primary);
    color: white;
    font-weight: 600;
}

.nav-link .icon {
    font-size: 1.25rem;
    opacity: 0.9;
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
}

.user-details {
    flex: 1;
}

.user-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.user-role {
    font-size: 0.8rem;
    opacity: 0.7;
}

.logout-btn {
    display: block;
    width: 100%;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: white;
    text-align: center;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
}

.logout-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}

/* Main Content */
.main-content {
    margin-left: 280px;
    flex: 1;
    min-height: 100vh;
    background: var(--bg-secondary);
}

.content-wrapper {
    padding: 1.5rem;
    max-width: 1400px;
    margin: 0 auto;
}

.page-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
}

/* Suppress Blazor's post-navigation focus ring on headings */
h1:focus, h2:focus, h3:focus, h4:focus,
h1:focus-visible, h2:focus-visible, h3:focus-visible, h4:focus-visible {
    outline: none;
}

.page-subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
}

/* Cards */
.card {
    background: var(--bg-primary);
    border-radius: 16px;
    padding: 1.25rem;
    box-shadow: var(--shadow);
    transition: all 0.2s ease;
}

.card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--bg-tertiary);
}

.card-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    font-family: inherit;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--border);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border);
    border-radius: 10px;
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.2s ease;
    background: var(--bg-primary);
    color: var(--text-primary);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 134, 163, 0.12);
}

select.form-control {
    cursor: pointer;
}

/* Table */
.table-wrapper {
    overflow-x: auto;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.table {
    width: 100%;
    background: var(--bg-primary);
    border-collapse: separate;
    border-spacing: 0;
}

.table thead {
    background: var(--bg-tertiary);
}

.table th {
    padding: 1rem 1.5rem;
    text-align: left;
    font-weight: 700;
    color: var(--text-primary);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.table td {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--bg-tertiary);
}

.table tbody tr {
    transition: background 0.15s ease;
}

.table tbody tr:hover {
    background: var(--bg-secondary);
}

/* Badge */
.badge {
    display: inline-block;
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: 'Rubik', sans-serif;
}

.badge-primary {
    background: rgba(0, 134, 163, 0.1);
    color: var(--primary);
}

.badge-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

/* Page Header — flex so action buttons sit inline on desktop */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

/* Grid */
.grid {
    display: grid;
    gap: 1.5rem;
}

.grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

/* Action bar — search + buttons row that wraps on mobile */
.action-bar {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
}

.action-bar .form-control {
    flex: 1;
    min-width: 180px;
}

/* Stats Cards */
.stat-card {
    background: var(--bg-primary);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    transition: all 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.dash-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.65rem 0.5rem;
    border-bottom: 1px solid var(--bg-tertiary);
    border-radius: 6px;
    transition: background 0.15s;
    text-decoration: none;
    color: inherit;
}
.dash-row:hover {
    background: var(--bg-secondary);
}

.stat-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* Loading */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 3rem;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--bg-tertiary);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ── Mobile Header ──────────────────────────────────────────────────────── */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--navy);
    z-index: 200;
    align-items: center;
    padding: 0 1rem;
    gap: 0.75rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.hamburger-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 5px;
    border-radius: 6px;
    transition: background 0.2s;
    min-width: 44px;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.hamburger-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.hamburger-btn span {
    display: block;
    width: 20px;
    height: 2px;
    background: white;
    border-radius: 2px;
}

/* ── Sidebar Overlay (mobile only) ─────────────────────────────────────── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
}

.sidebar-overlay.active {
    display: block;
}

/* ── Bottom Navigation (mobile) ────────────────────────────────────────── */
.bottom-nav {
    display: none;
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
    .sidebar {
        width: 220px;
    }

    .main-content {
        margin-left: 220px;
    }

    .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    /* Show mobile header */
    .mobile-header {
        display: flex;
    }

    /* Sidebar becomes a slide-in drawer */
    .sidebar {
        width: 280px;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

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

    /* Icon sizing when sidebar logo switches to icon on narrow viewports */
    .sidebar-logo {
        width: 36px;
        height: 36px;
        object-position: center center;
    }

    /* Main content goes full-width, below the 60px header */
    .main-content {
        margin-left: 0;
        padding-top: 60px;
        padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px));
    }

    .content-wrapper {
        padding: 1.25rem 1rem;
    }

    /* Typography */
    .page-title {
        font-size: 1.5rem;
    }

    .page-subtitle {
        font-size: 0.875rem;
    }

    /* Page header stacks on mobile */
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
        margin-bottom: 0.75rem;
    }

    .page-header > div:last-child {
        width: 100%;
    }

    .page-header .btn,
    .page-header a.btn {
        flex: 1;
        justify-content: center;
        text-align: center;
    }

    /* Cards */
    .card {
        border-radius: 12px;
        padding: 1rem;
    }

    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    /* Grids collapse to 1 column */
    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
    }

    /* Action bar stacks vertically */
    .action-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .action-bar .btn,
    .action-bar a.btn {
        justify-content: center;
        text-align: center;
    }

    .action-bar .form-control {
        flex: none;
        width: 100%;
        min-width: unset;
    }

    /* Stat cards */
    .stat-value {
        font-size: 1.75rem;
    }

    /* Tables: horizontal scroll with touch momentum */
    .table-wrapper {
        -webkit-overflow-scrolling: touch;
        margin: 0 -1rem;         /* bleed to card edges so scrollbar reaches edge */
        width: calc(100% + 2rem);
        border-radius: 0;
    }

    .table th,
    .table td {
        padding: 0.75rem 1rem;
        white-space: nowrap;
    }

    /* Touch targets */
    .btn-sm {
        min-height: 44px;
        min-width: 44px;
    }

    /* Bottom nav */
    .bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: calc(56px + env(safe-area-inset-bottom, 0px));
        padding-bottom: env(safe-area-inset-bottom, 0px);
        background: var(--navy);
        z-index: 200;
        box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.3);
    }

    .bottom-nav-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 0.15rem;
        font-size: 0.65rem;
        font-weight: 500;
        font-family: inherit;
        color: rgba(255, 255, 255, 0.6);
        text-decoration: none;
        background: none;
        border: none;
        cursor: pointer;
        padding: 0.25rem 0;
        transition: color 0.2s;
    }

    .bottom-nav-item:hover,
    .bottom-nav-item.active {
        color: white;
    }

    .bottom-nav-icon {
        font-size: 1.25rem;
        line-height: 1;
    }

    /* Login card */
    .login-card {
        padding: 2rem 1.5rem !important;
    }
}

@media (max-width: 480px) {
    .content-wrapper {
        padding: 1rem 0.75rem;
    }

    .page-title {
        font-size: 1.25rem;
    }
}

/* ── Tag chip — teal pill used on asset tags ────────────────────────────── */
.tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: var(--primary);
    color: #fff;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.2rem 0.65rem;
}

.tag-chip-sm {
    font-size: 0.7rem;
    padding: 0.1rem 0.5rem;
}

.tag-chip-xs {
    font-size: 0.65rem;
    padding: 0.1rem 0.4rem;
}

.tag-chip-remove {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    font-size: 1rem;
}

/* Error / alert box used on asset forms */
.alert-error {
    background: #fee2e2;
    border: 2px solid var(--danger);
    border-radius: 8px;
    padding: 1rem;
    margin: 1rem 0;
    color: #b91c1c;
}

/* ── Dark mode overrides ────────────────────────────────────────────────── */
[data-theme="dark"] .form-control::placeholder {
    color: rgba(148, 163, 184, 0.5);
}

/* Badges — readable on dark card backgrounds (#1e2533) */
[data-theme="dark"] .badge-primary {
    background: rgba(0, 134, 163, 0.25);
    color: #5ac8df;
}

[data-theme="dark"] .badge-success {
    background: rgba(16, 185, 129, 0.2);
    color: #34d399;
}

[data-theme="dark"] .badge-warning {
    background: rgba(245, 158, 11, 0.2);
    color: #fbbf24;
}

[data-theme="dark"] .badge-danger {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
}

/* Tag chips — muted teal so they don't blaze on dark backgrounds */
[data-theme="dark"] .tag-chip {
    background: rgba(0, 134, 163, 0.35);
    color: #a5e3ef;
}

/* Error alert box — dark-mode version */
[data-theme="dark"] .alert-error {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.5);
    color: #f87171;
}

/* Action feedback messages (check-out / check-in result) */
[data-theme="dark"] .action-msg-success {
    background: rgba(16, 185, 129, 0.15) !important;
    border-color: rgba(16, 185, 129, 0.4) !important;
    color: #34d399 !important;
}

[data-theme="dark"] .action-msg-danger {
    background: rgba(239, 68, 68, 0.15) !important;
    border-color: rgba(239, 68, 68, 0.4) !important;
    color: #f87171 !important;
}

[data-theme="dark"] .login-logo-img {
    content: url('/images/branding/Renderpath_Logo2_White.png');
}

/* Blazor Error UI */
#blazor-error-ui {
    background: var(--danger);
    color: white;
    padding: 1rem;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    display: none;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
}

/* Toast slide-in animation */
@keyframes toastSlideIn {
    from { opacity: 0; transform: translateX(100%); }
    to   { opacity: 1; transform: translateX(0); }
}
