/* =========================================================
   APPLICATION LAYOUT
========================================================= */

:root {
    --sidebar-width: 260px;
    --topbar-height: 72px;

    --layout-bg: #f7f5f2;
    --sidebar-bg: #ffffff;
    --topbar-bg: #ffffff;

    --layout-border: rgba(73, 55, 40, 0.09);

    --layout-text: #302820;
    --layout-muted: #8b8178;

    --layout-primary: #6f4e37;
    --layout-primary-dark: #563b2a;
    --layout-primary-soft: #f2ebe5;

    --layout-danger: #c0392b;
    --layout-danger-soft: #fceceb;

    --layout-radius: 14px;
    --layout-transition: 0.2s ease;
}

/* =========================================================
   BODY
========================================================= */

.app-body {
    min-height: 100vh;
    margin: 0;
    background: var(--layout-bg);
    color: var(--layout-text);
    font-family:
        Inter,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
}

/* =========================================================
   APP WRAPPER
========================================================= */

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

/* =========================================================
   SIDEBAR
========================================================= */

.app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1050;

    width: var(--sidebar-width);

    display: flex;
    flex-direction: column;

    background: var(--sidebar-bg);
    border-right: 1px solid var(--layout-border);

    transition:
        transform var(--layout-transition),
        box-shadow var(--layout-transition);
}

/* =========================================================
   SIDEBAR HEADER
========================================================= */

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

.sidebar-brand {
    height: var(--topbar-height);

    display: flex;
    align-items: center;

    gap: 12px;
    padding: 0 22px;

    border-bottom: 1px solid var(--layout-border);

    color: var(--layout-text);
    text-decoration: none;
}

.sidebar-brand:hover {
    color: var(--layout-text);
    text-decoration: none;
}

.sidebar-brand-icon {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 11px;

    background: var(--layout-primary);
    color: #ffffff;

    font-size: 1.05rem;

    box-shadow: 0 5px 12px rgba(111, 78, 55, 0.2);
}

.sidebar-brand-text {
    min-width: 0;

    display: flex;
    flex-direction: column;
}

.sidebar-brand-text strong {
    font-size: 0.95rem;
    font-weight: 750;
    line-height: 1.2;
    letter-spacing: -0.01em;
}

.sidebar-brand-text span {
    margin-top: 2px;

    color: var(--layout-muted);

    font-size: 0.68rem;
    font-weight: 500;
}

/* =========================================================
   SIDEBAR NAV
========================================================= */

.sidebar-nav {
    flex: 1;

    overflow-y: auto;

    padding: 18px 14px;
}

.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(111, 78, 55, 0.15);
    border-radius: 99px;
}

/* =========================================================
   SIDEBAR SECTION
========================================================= */

.sidebar-section {
    margin-bottom: 20px;
}

.sidebar-section:last-child {
    margin-bottom: 0;
}

.sidebar-section-title {
    display: block;

    margin: 0 14px 7px;

    color: #9b9189;

    font-size: 0.61rem;
    font-weight: 700;

    letter-spacing: 0.08em;
}

/* =========================================================
   SIDEBAR LINK
========================================================= */

.sidebar-link {
    position: relative;

    display: flex;
    align-items: center;

    gap: 11px;

    min-height: 39px;

    margin: 2px 8px;
    padding: 8px 11px;

    border-radius: 8px;

    color: #756b63;

    text-decoration: none;

    font-size: 0.76rem;

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

.sidebar-link i {
    width: 18px;

    flex: 0 0 18px;

    font-size: 0.92rem;

    text-align: center;
}

.sidebar-link span {
    flex: 1;

    min-width: 0;
}

.sidebar-link:hover {
    background: #f7f4f1;

    color: var(--layout-primary);

    text-decoration: none;
}

.sidebar-link.active {
    background: #f1eae4;

    color: var(--layout-primary);

    font-weight: 600;
}

.sidebar-link.active::before {
    content: "";

    position: absolute;

    left: 0;
    top: 8px;
    bottom: 8px;

    width: 3px;

    border-radius: 0 3px 3px 0;

    background: var(--layout-primary);
}

/* =========================================================
   DISABLED SIDEBAR LINK
========================================================= */

.sidebar-link.disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.sidebar-link.disabled:hover {
    background: transparent;
    color: #756b63;
}

.sidebar-link.disabled small {
    margin-left: auto;

    padding: 2px 6px;

    border-radius: 5px;

    background: #f0ece8;
    color: #9b9189;

    font-size: 0.56rem;
    font-weight: 600;

    line-height: 1.3;
}

/* =========================================================
   SIDEBAR FOOTER
========================================================= */

.sidebar-footer {
    flex-shrink: 0;

    padding: 12px 14px 16px;

    border-top: 1px solid var(--layout-border);

    background: #ffffff;
}

/* =========================================================
   SYSTEM STATUS
========================================================= */

.sidebar-status {
    display: flex;
    align-items: center;

    gap: 10px;

    margin: 0 8px 10px;
    padding: 9px 10px;

    border-radius: 9px;

    background: #faf8f6;
}

.sidebar-status-dot {
    width: 8px;
    height: 8px;

    flex: 0 0 8px;

    border-radius: 50%;

    background: #48a868;

    box-shadow: 0 0 0 3px rgba(72, 168, 104, 0.1);
}

.sidebar-status-info {
    min-width: 0;

    display: flex;
    flex-direction: column;
}

.sidebar-status-info strong {
    color: #5d544d;

    font-size: 0.66rem;
    font-weight: 650;

    line-height: 1.2;
}

.sidebar-status-info span {
    margin-top: 2px;

    color: #a09790;

    font-size: 0.58rem;
}

/* =========================================================
   LOGOUT
========================================================= */

.sidebar-logout-form {
    margin: 0;
}

.sidebar-logout-button {
    width: 100%;

    display: flex;
    align-items: center;

    gap: 11px;

    padding: 9px 11px;

    border: 0;
    border-radius: 8px;

    background: transparent;

    color: #9b5149;

    font-size: 0.74rem;

    text-align: left;

    cursor: pointer;

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

.sidebar-logout-button i {
    width: 18px;

    flex: 0 0 18px;

    font-size: 0.92rem;

    text-align: center;
}

.sidebar-logout-button:hover {
    background: #fdf1ef;
    color: #a83d34;
}

/* =========================================================
   MAIN
========================================================= */

.app-main {
    min-width: 0;

    width: calc(100% - var(--sidebar-width));

    min-height: 100vh;

    margin-left: var(--sidebar-width);

    display: flex;
    flex-direction: column;
}

/* =========================================================
   TOPBAR
========================================================= */

.app-topbar {
    position: sticky;

    top: 0;

    z-index: 900;

    height: var(--topbar-height);

    display: flex;
    align-items: center;

    padding: 0 28px;

    background: rgba(255, 255, 255, 0.94);

    border-bottom: 1px solid var(--layout-border);

    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.topbar-spacer {
    flex: 1;
}

/* =========================================================
   MOBILE MENU BUTTON
========================================================= */

.mobile-menu-button {
    width: 40px;
    height: 40px;

    display: none;

    align-items: center;
    justify-content: center;

    border: 1px solid var(--layout-border);
    border-radius: 10px;

    background: #ffffff;

    color: var(--layout-text);

    font-size: 1.15rem;

    cursor: pointer;

    transition:
        background-color var(--layout-transition),
        color var(--layout-transition);
}

.mobile-menu-button:hover {
    background: var(--layout-primary-soft);
    color: var(--layout-primary);
}

/* =========================================================
   TOPBAR PROFILE
========================================================= */

.topbar-profile {
    display: flex;
    align-items: center;

    gap: 10px;

    padding: 5px 6px 5px 10px;

    border-radius: 11px;

    color: inherit;
    text-decoration: none;

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

.topbar-profile:hover {
    background: #f7f4f1;

    color: inherit;
    text-decoration: none;
}

.topbar-profile-info {
    min-width: 0;

    display: flex;
    flex-direction: column;
    align-items: flex-end;

    line-height: 1.2;
}

.topbar-profile-info strong {
    max-width: 180px;

    overflow: hidden;

    color: var(--layout-text);

    font-size: 0.78rem;
    font-weight: 650;

    text-overflow: ellipsis;
    white-space: nowrap;
}

.topbar-profile-info span {
    margin-top: 3px;

    color: var(--layout-muted);

    font-size: 0.64rem;

    text-transform: capitalize;
}

/* =========================================================
   TOPBAR AVATAR
========================================================= */

.topbar-avatar {
    width: 38px;
    height: 38px;

    flex: 0 0 38px;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 50%;

    background: var(--layout-primary);

    color: #ffffff;

    font-size: 0.78rem;
    font-weight: 750;

    box-shadow: 0 4px 10px rgba(111, 78, 55, 0.18);

    transition:
        transform 0.2s ease,
        box-shadow 0.2s ease;
}

.topbar-profile:hover .topbar-avatar {
    transform: translateY(-1px);

    box-shadow: 0 5px 13px rgba(111, 78, 55, 0.22);
}

/* =========================================================
   TOPBAR ARROW
========================================================= */

.topbar-profile-arrow {
    color: #a59b94;

    font-size: 0.62rem;

    transition: transform 0.2s ease;
}

.topbar-profile:hover .topbar-profile-arrow {
    transform: translateY(1px);
}

/* =========================================================
   CONTENT
========================================================= */

.app-content {
    flex: 1;

    width: 100%;

    padding: 28px;
}

/* =========================================================
   PAGE HEADER
========================================================= */

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;

    gap: 20px;

    margin-bottom: 24px;
}

.page-header-content {
    min-width: 0;
}

.page-title {
    margin: 0;

    color: var(--layout-text);

    font-size: 1.45rem;
    font-weight: 750;

    letter-spacing: -0.025em;
}

.page-subtitle {
    margin: 6px 0 0;

    color: var(--layout-muted);

    font-size: 0.84rem;

    line-height: 1.6;
}

.page-header-actions {
    display: flex;
    align-items: center;

    gap: 8px;

    flex-shrink: 0;
}

/* =========================================================
   SIDEBAR OVERLAY
========================================================= */

.sidebar-overlay {
    position: fixed;

    inset: 0;

    z-index: 1040;

    display: none;

    background: rgba(20, 18, 16, 0.42);

    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

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

body.sidebar-open {
    overflow: hidden;
}

/* =========================================================
   RESPONSIVE - TABLET
========================================================= */

@media (max-width: 991.98px) {
    .app-sidebar {
        transform: translateX(-100%);

        box-shadow: none;
    }

    .app-sidebar.show {
        transform: translateX(0);

        box-shadow: 12px 0 35px rgba(0, 0, 0, 0.12);
    }

    .app-main {
        width: 100%;

        margin-left: 0;
    }

    .mobile-menu-button {
        display: inline-flex;
    }

    .app-topbar {
        padding: 0 20px;
    }

    .app-content {
        padding: 22px;
    }
}

/* =========================================================
   RESPONSIVE - MOBILE
========================================================= */

@media (max-width: 575.98px) {
    :root {
        --topbar-height: 64px;
    }

    .app-topbar {
        padding: 0 15px;
    }

    .topbar-profile {
        padding: 4px;
    }

    .topbar-profile-info {
        display: none;
    }

    .topbar-avatar {
        width: 36px;
        height: 36px;

        flex-basis: 36px;
    }

    .topbar-profile-arrow {
        display: none;
    }

    .app-content {
        padding: 18px 14px;
    }

    .page-header {
        flex-direction: column;

        gap: 14px;

        margin-bottom: 18px;
    }

    .page-header-actions {
        width: 100%;
    }

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

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

    .sidebar-footer {
        padding: 10px 12px 14px;
    }

    .sidebar-status {
        margin-left: 8px;
        margin-right: 8px;
    }
}

/* =========================================================
   VERY SMALL MOBILE
========================================================= */

@media (max-width: 375px) {
    .app-content {
        padding: 16px 12px;
    }

    .sidebar-brand {
        padding: 0 18px;
    }

    .sidebar-nav {
        padding-left: 10px;
        padding-right: 10px;
    }

    .sidebar-footer {
        padding-left: 10px;
        padding-right: 10px;
    }
}
