/* =====================================================
   DASHBOARD SHARED LAYOUT
   Shared shell for Dashboard and profile pages.
   ===================================================== */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --sidebar-width: 270px;

    --primary: #b28a2e;
    --primary-dark: #1c1b1b;
    --primary-soft: #fff8e8;

    --background: #f4f6f8;
    --surface: #ffffff;
    --surface-soft: #f7f7f7;

    --text-main: #1c1b1b;
    --text-secondary: #6b7280;
    --text-light: #9ca3af;

    --border: #d1d5db;
    --border-soft: #ffffff;

    --detail-icon-bg: #edf4ef;
    --detail-icon: #355b46;
    --detail-surface: #fafcfb;
    --detail-border: #edf1ee;

    --sidebar-top: #071008;
    --sidebar-middle: #0b160d;
    --sidebar-bottom: #0d1710;
    --sidebar-text: #c7d2c8;

    --shadow-sm: 0 4px 14px rgba(15, 23, 42, 0.05);
    --shadow-md: 0 12px 32px rgba(15, 23, 42, 0.08);
}

html {
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    background: var(--background);
    color: var(--text-main);
    font-family: "Prompt", "Noto Sans Thai", sans-serif;
}

button,
input,
textarea,
select {
    font: inherit;
}

button,
a,
label {
    -webkit-tap-highlight-color: transparent;
}

a {
    color: inherit;
    text-decoration: none;
}

img {
    display: block;
    max-width: 100%;
}

.dashboard-layout {
    min-height: 100vh;
}

.dashboard-main {
    min-height: 100vh;
    margin-left: var(--sidebar-width);
    padding: 28px 32px 50px;
    transition: margin-left 0.3s ease;
}

/* Sidebar */
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 100;

    display: flex;
    flex-direction: column;

    width: var(--sidebar-width);
    height: 100vh;

    background: linear-gradient(
        180deg,
        var(--sidebar-top) 0%,
        var(--sidebar-middle) 45%,
        var(--sidebar-bottom) 100%
    );
    color: #ffffff;
    box-shadow: 8px 0 30px rgba(0, 0, 0, 0.20);

    transition:
        width 0.3s ease,
        transform 0.3s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: center;

    width: 100%;
    height: 140px;
    min-height: 140px;
    padding: 12px 16px;

    background: var(--sidebar-top);
    border-bottom: 1px solid rgba(111, 164, 66, 0.14);
}

.brand-logo {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;

    width: 220px;
    height: 105px;
    overflow: hidden;

    background: transparent;
    border: none;
    border-radius: 8px;
}

.brand-logo img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    transform: scale(1.55);
    transform-origin: center;
}

.sidebar-menu {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 7px;

    padding: 20px 16px;
    overflow-y: auto;
}

.menu-link {
    display: grid;
    grid-template-columns: 24px 1fr 18px;
    align-items: center;
    gap: 12px;

    min-height: 50px;
    padding: 0 15px;
    color: var(--sidebar-text);
    border-radius: 12px;

    transition:
        background 0.2s ease,
        color 0.2s ease,
        transform 0.2s ease;
}

.menu-link > i:first-child {
    font-size: 18px;
}

.menu-link span {
    min-width: 0;
    overflow: hidden;
    font-size: 14px;
    font-weight: 500;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.menu-arrow {
    color: #657568;
    font-size: 13px;
}

.menu-link:hover {
    background: rgba(117, 164, 72, 0.12);
    color: #ffffff;
    transform: translateX(3px);
}

.menu-link.active {
    background: linear-gradient(135deg, #c9a348, #9f7924);
    color: #ffffff;
    box-shadow: 0 8px 20px rgba(178, 138, 46, 0.24);
}

.menu-link.active .menu-arrow {
    color: #ffffff;
}

.sidebar-bottom,
.sidebar-footer {
    padding: 14px 16px 22px;
    border-top: 1px solid rgba(126, 170, 79, 0.14);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.logout-link {
    display: flex;
    align-items: center;
    gap: 12px;

    min-height: 48px;
    padding: 0 15px;
    color: #fca5a5;
    border-radius: 12px;

    transition:
        background 0.2s ease,
        color 0.2s ease;
}

.logout-link:hover {
    background: rgba(239, 68, 68, 0.12);
    color: #fecaca;
}

/* Topbar */
.dashboard-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 26px;
}

.dashboard-topbar h1 {
    font-size: 38px;
    font-weight: 600;
    letter-spacing: 0;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.top-search {
    display: flex;
    align-items: center;
    gap: 10px;

    width: 280px;
    height: 48px;
    padding: 0 18px;

    background: #ffffff;
    border-radius: 999px;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.06);
}

.top-search input {
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    font-size: 13px;
}

.icon-btn {
    position: relative;
    display: grid;
    place-items: center;

    width: 48px;
    height: 48px;
    background: #ffffff;
    color: #111827;
    border: none;
    border-radius: 999px;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.06);
    cursor: pointer;
    transition: 0.25s ease;
}

.icon-btn:hover {
    background: #111827;
    color: #ffffff;
    transform: translateY(-3px);
}

.icon-btn:focus-visible {
    outline: 3px solid rgba(53, 91, 70, 0.22);
    outline-offset: 2px;
}

.notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;

    display: grid;
    place-items: center;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;

    background: #dc2626;
    color: #ffffff;
    border: 2px solid #f4f6f8;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;

    min-width: 0;
    height: 52px;
    padding: 6px 14px 6px 6px;

    background: #ffffff;
    border-radius: 999px;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.06);
    cursor: default;
}

.user-avatar {
    display: flex;
    flex: 0 0 40px;
    align-items: center;
    justify-content: center;

    width: 40px;
    height: 40px;
    background: #111827;
    color: #ffffff;
    border-radius: 999px;
}

.user-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
    max-width: 128px;
}

.user-info strong,
.user-info span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-info strong {
    font-size: 13px;
}

.user-info span {
    color: var(--text-secondary);
    font-size: 11px;
}

/* Animation */
.reveal {
    opacity: 0;
    transform: translateY(12px);
    transition:
        opacity var(--motion-normal, 220ms) ease,
        transform var(--motion-normal, 220ms) var(--motion-ease, ease);
}

.reveal.show {
    opacity: 1;
    transform: translateY(0);
}

/* Responsive shell */
@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
    }

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

    .dashboard-main {
        margin-left: 0;
        padding: 20px;
    }
}

@media (max-width: 768px) {
    .dashboard-topbar {
        align-items: stretch;
        flex-direction: column;
    }

    .dashboard-topbar h1 {
        font-size: 28px;
    }

    .topbar-actions {
        width: 100%;
        flex-wrap: wrap;
        justify-content: space-between;
    }

    .top-search {
        width: 100%;
    }
}

@media (max-width: 520px) {
    .dashboard-main {
        padding: 14px;
    }

    .dashboard-topbar {
        padding: 15px;
        border-radius: 15px;
    }

    .user-info {
        display: none;
    }
}