/* Admin layout - IMS */

:root {
    --sidebar-width: 272px;
    --sidebar-collapsed-width: 80px;
    --sidebar-bg: #f7f8fa;
    --sidebar-text: #4b5563;
    --sidebar-text-strong: #111827;
    --sidebar-hover: #eef1f5;
    --sidebar-active: #1e3a5f;
    --sidebar-active-bg: #e8eef5;
    --accent: #1e3a5f;
    --accent-soft: #e8eef5;
    --header-height: 72px;
    --surface: #ffffff;
    --page-bg: #f3f4f6;
    --border: #e5e7eb;
    --text: #111827;
    --muted: #6b7280;
    --radius: 12px;
    --shadow-sm: 0 1px 2px rgba(17, 24, 39, 0.05);
    --shadow-md: 0 8px 24px rgba(17, 24, 39, 0.08);
}

html,
body {
    height: 100%;
    min-height: 100%;
    min-height: 100dvh;
    min-height: -webkit-fill-available;
}

body {
    background-color: var(--page-bg);
    color: var(--text);
    font-family: Inter, system-ui, -apple-system, sans-serif;
}

.admin-wrapper {
    display: flex;
    min-height: 100%;
    min-height: 100dvh;
}

.admin-sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    height: auto;
    min-height: 100%;
    min-height: 100dvh;
    min-height: -webkit-fill-available;
    padding-bottom: env(safe-area-inset-bottom);
    z-index: 1030;
    transition: transform 0.22s ease, width 0.22s ease;
    overflow-x: hidden;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
}

.admin-sidebar .sidebar-brand {
    padding: 1.25rem 1.15rem 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-logo {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #1e3a5f;
    color: #fff;
    font-size: 1.15rem;
}

.sidebar-brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
    min-width: 0;
}

.sidebar-brand-name {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--sidebar-text-strong);
}

.sidebar-brand-sub {
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--muted);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.sidebar-nav {
    padding: 0.35rem 0.85rem 1rem;
    flex: 1 1 auto;
    min-height: 0;
}

.sidebar-label {
    margin: 1.05rem 0.65rem 0.4rem;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #9ca3af;
}

.sidebar-label:first-child {
    margin-top: 0.25rem;
}

.admin-sidebar .nav-link {
    color: var(--sidebar-text);
    padding: 0.62rem 0.75rem;
    margin-bottom: 0.2rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-radius: 10px;
    font-size: 0.925rem;
    font-weight: 500;
    border: 0;
    transition: background 0.15s ease, color 0.15s ease;
}

.admin-sidebar .nav-link:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text-strong);
}

.admin-sidebar .nav-link.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active);
    font-weight: 600;
}

.admin-sidebar .nav-link i {
    font-size: 1.05rem;
    width: 1.4rem;
    text-align: center;
    opacity: 0.95;
}

.admin-sidebar .sidebar-footer {
    padding: 0.85rem;
    margin-top: auto;
    border-top: 1px solid var(--border);
}

.sidebar-logout {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.62rem 0.75rem;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: #6b7280;
    font-size: 0.925rem;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.sidebar-logout i {
    font-size: 1.05rem;
    width: 1.4rem;
    text-align: center;
}

.sidebar-logout:hover {
    background: #fef2f2;
    color: #b91c1c;
}

.sidebar-overlay {
    display: none;
}

.admin-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left 0.22s ease;
}

.admin-header {
    min-height: var(--header-height);
    background: rgba(255, 255, 255, 0.86);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 0.65rem clamp(0.75rem, 2.5vw, 1.5rem);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 0.75rem;
    position: sticky;
    top: 0;
    z-index: 1020;
}

.header-left,
.header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.header-left {
    flex: 1 1 auto;
}

.header-right {
    flex: 0 0 auto;
}

.header-icon-btn {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: #334155;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    box-shadow: var(--shadow-sm);
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.header-icon-btn i {
    font-size: 1.15rem;
}

.header-icon-btn:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: var(--text);
}

.header-title-wrap {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1 1 auto;
}

.header-kicker {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.header-title {
    margin: 0;
    font-size: clamp(0.95rem, 2.4vw, 1.15rem);
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-meta {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    min-width: 11.5rem;
    max-width: 100%;
    padding: 0.45rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: #f8fafc;
    color: var(--muted);
    font-size: 0.8125rem;
    font-weight: 500;
    justify-content: center;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    flex-shrink: 1;
}

.header-meta i {
    color: #1e3a5f;
    flex-shrink: 0;
}

#headerClock {
    transition: opacity 0.2s ease;
    overflow: hidden;
    text-overflow: ellipsis;
}

#headerClock.header-clock-swap {
    opacity: 0.35;
}

.header-profile {
    flex-shrink: 0;
}

.header-user {
    width: 40px;
    height: 40px;
    min-width: 40px;
    aspect-ratio: 1 / 1;
    padding: 0;
    margin: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    box-shadow: none;
    cursor: pointer;
    color: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    line-height: 0;
    appearance: none;
    -webkit-appearance: none;
}

.header-user:hover,
.header-user[aria-expanded="true"] {
    background: transparent;
}

.header-user:focus-visible {
    outline: 2px solid #1e3a5f;
    outline-offset: 2px;
}

.header-avatar {
    width: 40px;
    height: 40px;
    min-width: 40px;
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #1e3a5f;
    color: #fff;
    font-size: 0.85rem;
    font-weight: 700;
    line-height: 1;
    overflow: hidden;
    flex-shrink: 0;
}

.header-user-caret {
    font-size: 0.7rem;
    color: var(--muted);
    transition: transform 0.15s ease;
}

.header-user[aria-expanded="true"] .header-user-caret {
    transform: rotate(180deg);
}

.header-profile-menu {
    min-width: min(220px, calc(100vw - 1.5rem));
    padding: 0.4rem 0;
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    margin-top: 0.35rem;
}

.header-profile-menu .dropdown-item {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.header-profile-menu .dropdown-item.active,
.header-profile-menu .dropdown-item:active {
    background: #e8eef5;
    color: #1e3a5f;
}

.header-profile-menu .dropdown-item.text-danger:active {
    background: #fef2f2;
    color: #b91c1c;
}

.header-user-copy {
    flex-direction: column;
    line-height: 1.15;
    padding-right: 0.25rem;
}

.header-user-name {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text);
}

.header-user-role {
    font-size: 0.7rem;
    color: var(--muted);
}

@media (max-width: 767.98px) {
    .admin-header {
        min-height: 60px;
    }

    .header-icon-btn,
    .header-user,
    .header-avatar {
        width: 36px;
        height: 36px;
        min-width: 36px;
    }

    .header-meta {
        min-width: 0;
        padding: 0.35rem 0.55rem;
        font-size: 0.72rem;
    }
}

@media (max-width: 575.98px) {
    .header-meta time {
        max-width: 6.5rem;
    }

    .header-icon-btn {
        border-radius: 50%;
    }
}

.admin-content {
    flex: 1;
    padding: 1.5rem;
}

.admin-content .card {
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    border-radius: var(--radius);
}

.admin-content .card-header {
    background: #fff;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    padding: 0.85rem 1.1rem;
}

.product-modal-section-title {
    letter-spacing: 0.05em;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid var(--border);
}

/* Desktop: collapsible sidebar (icon-only) */
@media (min-width: 992px) {
    body.sidebar-collapsed .admin-sidebar {
        width: var(--sidebar-collapsed-width);
        min-width: var(--sidebar-collapsed-width);
    }

    body.sidebar-collapsed .admin-main {
        margin-left: var(--sidebar-collapsed-width);
    }

    body.sidebar-collapsed .sidebar-brand-text,
    body.sidebar-collapsed .sidebar-label,
    body.sidebar-collapsed .admin-sidebar .nav-link span,
    body.sidebar-collapsed .sidebar-logout span {
        display: none;
    }

    body.sidebar-collapsed .admin-sidebar .sidebar-brand,
    body.sidebar-collapsed .admin-sidebar .nav-link,
    body.sidebar-collapsed .sidebar-logout {
        justify-content: center;
        padding-left: 0.6rem;
        padding-right: 0.6rem;
        gap: 0;
    }

    body.sidebar-collapsed .admin-sidebar .sidebar-nav {
        padding-left: 0.7rem;
        padding-right: 0.7rem;
    }

    body.sidebar-collapsed .admin-sidebar .nav-link i,
    body.sidebar-collapsed .sidebar-logout i {
        width: auto;
    }
}

/* Mobile: sidebar offcanvas */
@media (max-width: 991.98px) {
    .admin-sidebar {
        transform: translateX(-100%);
        box-shadow: none;
        top: 0;
        bottom: 0;
        height: auto;
        min-height: 100dvh;
        min-height: -webkit-fill-available;
    }

    .admin-sidebar.show {
        transform: translateX(0);
        box-shadow: 8px 0 32px rgba(17, 24, 39, 0.12);
    }

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

    .sidebar-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(17, 24, 39, 0.4);
        z-index: 1025;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.2s ease;
    }

    .sidebar-overlay.is-visible {
        opacity: 1;
        pointer-events: auto;
    }
}

