/* =====================================================
   Layout - App shell with collapsible sidebar
   ===================================================== */

.app-shell {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--color-sidebar-bg);
    color: var(--color-sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
    transition: width var(--duration-base) var(--ease);
    overflow: hidden;
}

.sidebar[data-collapsed="true"] {
    width: var(--sidebar-width-mini);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-3) var(--space-3) var(--space-4);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    min-height: auto;
    gap: var(--space-2);
    flex-direction: column;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    flex-direction: column;
    gap: var(--space-2);
    color: var(--color-text-invert);
    text-decoration: none;
    flex: 1;
    min-width: 0;
    padding: var(--space-2) 0;
    text-align: center;
}

.logo-mark {
    width: 100px;
    height: 40px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    background: transparent;
    margin: 0 auto;
}

.logo-mark img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.logo-mini {
    display: none;
    width: 56px;
    height: 22px;
    border-radius: var(--radius-xs);
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    background: transparent;
    margin: 0 auto;
}

.logo-mini img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.logo-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
    min-width: 0;
    transition: opacity var(--duration-base) var(--ease);
    text-align: center;
}

.logo-name {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 15px;
    color: var(--color-text-invert);
    white-space: nowrap;
}

.logo-tagline {
    font-size: 11px;
    color: var(--color-sidebar-text-muted);
    white-space: nowrap;
}

.sidebar[data-collapsed="true"] .logo-text,
.sidebar[data-collapsed="true"] .logo-mark {
    display: none;
}

.sidebar[data-collapsed="true"] .logo-mini {
    display: flex;
}

.sidebar-toggle {
    position: fixed;
    top: 50%;
    left: calc(var(--sidebar-width) - 14px);
    transform: translateY(-50%);
    z-index: 110;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    color: #FFFFFF;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: left var(--duration-base) var(--ease), background var(--duration-fast) var(--ease), color var(--duration-fast) var(--ease);
    flex-shrink: 0;
    background: linear-gradient(135deg, var(--color-accent-orange), var(--color-accent-orange-d));
    border: 2px solid var(--color-bg-soft);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.20);
}

.sidebar-toggle:hover {
    background: linear-gradient(135deg, var(--color-accent-orange-d), var(--color-accent-orange));
    color: var(--color-text-invert);
}

.app-shell[data-sidebar-collapsed="true"] .sidebar-toggle {
    left: calc(var(--sidebar-width-mini) - 14px);
}

.sidebar-toggle svg {
    transition: transform var(--duration-base) var(--ease);
}

.app-shell[data-sidebar-collapsed="true"] .sidebar-toggle svg {
    transform: rotate(180deg);
}

/* Nav */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--space-4) var(--space-3);
}

.nav-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 10px 12px;
    border-radius: var(--radius-md);
    color: var(--color-sidebar-text);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    position: relative;
    transition: background var(--duration-fast) var(--ease), color var(--duration-fast) var(--ease);
    white-space: nowrap;
    overflow: hidden;
}

.nav-link:hover {
    background: var(--color-sidebar-hover);
    color: var(--color-accent-orange);
}

.nav-link:hover svg {
    color: var(--color-accent-orange);
}

.nav-item.active .nav-link {
    background: var(--color-sidebar-active);
    color: var(--color-accent-orange);
    box-shadow: inset 3px 0 0 var(--color-accent-orange);
}

.nav-item.active .nav-link svg {
    color: var(--color-accent-orange);
}

.nav-item.active .nav-link .nav-label {
    color: #FFFFFF;
    font-weight: 700;
}

.nav-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    color: var(--color-sidebar-text);
    transition: color var(--duration-fast) var(--ease);
}

.nav-label {
    flex: 1;
    transition: opacity var(--duration-base) var(--ease);
}

.sidebar[data-collapsed="true"] .nav-label {
    opacity: 0;
    width: 0;
}

.nav-badge {
    background: var(--color-accent-red);
    color: var(--color-text-invert);
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: var(--radius-full);
    min-width: 18px;
    text-align: center;
}

.sidebar[data-collapsed="true"] .nav-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    padding: 0;
    width: 8px;
    height: 8px;
    min-width: 8px;
    border-radius: 50%;
    font-size: 0;
}

.sidebar[data-collapsed="true"] .nav-link {
    position: relative;
}

/* Tooltip for collapsed state */
.sidebar[data-collapsed="true"] .nav-link::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 12px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--color-primary-800);
    color: var(--color-text-invert);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--duration-fast) var(--ease);
    box-shadow: var(--shadow-md);
    z-index: 200;
}

.sidebar[data-collapsed="true"] .nav-link:hover::after {
    opacity: 1;
}

/* Sidebar footer */
.sidebar-footer {
    padding: var(--space-3);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.04);
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-accent-orange), var(--color-accent-orange-d));
    color: var(--color-text-invert);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(244, 162, 97, 0.30);
}

.avatar-sm { width: 30px; height: 30px; font-size: 12px; }

.user-info {
    flex: 1;
    min-width: 0;
    transition: opacity var(--duration-base) var(--ease);
}

.user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-invert);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 11px;
    color: var(--color-sidebar-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar[data-collapsed="true"] .user-info {
    opacity: 0;
    width: 0;
}

/* Main area */
.main {
    flex: 1;
    margin-left: var(--sidebar-width);
    transition: margin-left var(--duration-base) var(--ease);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-shell[data-sidebar-collapsed="true"] .main,
.sidebar[data-collapsed="true"] ~ .main {
    margin-left: var(--sidebar-width-mini);
}

/* Topbar */
.topbar {
    height: var(--topbar-height);
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-6);
    gap: var(--space-4);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    flex: 1;
    min-width: 0;
}

.hamburger {
    display: none;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    color: var(--color-text);
    transition: background var(--duration-fast) var(--ease);
}

.hamburger:hover { background: rgba(19, 120, 116, 0.06); }

.page-title h1 {
    font-size: 18px;
    font-weight: 700;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

/* Lang switcher */
.lang-switch {
    display: flex;
    background: rgba(19, 120, 116, 0.06);
    border-radius: var(--radius-full);
    padding: 3px;
    gap: 2px;
}

.lang-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 700;
    border-radius: var(--radius-full);
    color: var(--color-text-muted);
    text-decoration: none;
    transition: all var(--duration-fast) var(--ease);
    letter-spacing: 0.5px;
}

.lang-flag {
    font-size: 14px;
    line-height: 1;
}

.lang-label {
    line-height: 1;
}

.lang-btn:hover { color: var(--color-text); }

.lang-btn.active {
    background: var(--color-primary-700);
    color: var(--color-text-invert);
    box-shadow: 0 2px 6px rgba(19, 120, 116, 0.25);
}

/* Topbar buttons */
.topbar-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text);
    transition: background var(--duration-fast) var(--ease);
    position: relative;
}

.topbar-btn:hover { background: rgba(19, 120, 116, 0.06); }

.notif-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    background: var(--color-accent-red);
    color: var(--color-text-invert);
    font-size: 9px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: var(--radius-full);
    min-width: 16px;
    text-align: center;
    border: 2px solid var(--color-bg-soft);
}

/* User button */
.user-btn {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: 4px 10px 4px 4px;
    border-radius: var(--radius-full);
    transition: background var(--duration-fast) var(--ease);
}

.user-btn:hover { background: rgba(19, 120, 116, 0.06); }

.user-btn-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text);
}

/* Dropdown */
.dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 280px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: all var(--duration-fast) var(--ease);
    z-index: 200;
    overflow: hidden;
}

.dropdown.open .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-header {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--color-border-soft);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    font-weight: 600;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 10px var(--space-4);
    color: var(--color-text);
    text-decoration: none;
    font-size: 13px;
    transition: background var(--duration-fast) var(--ease);
}

.dropdown-item:hover { background: rgba(19, 120, 116, 0.05); }

.dropdown-item.text-danger { color: var(--color-accent-red); }
.dropdown-item.text-danger:hover { background: rgba(230, 57, 70, 0.08); }

.user-menu-header {
    padding: var(--space-4);
    border-bottom: 1px solid var(--color-border-soft);
}

.user-menu-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--color-text);
}

.user-menu-role {
    font-size: 12px;
    color: var(--color-text-muted);
    margin-top: 2px;
}

/* Notif menu */
.notif-list {
    max-height: 380px;
    overflow-y: auto;
}

.notif-empty {
    padding: var(--space-8) var(--space-4);
    text-align: center;
    color: var(--color-text-soft);
    font-size: 13px;
}

.notif-item {
    display: block;
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--color-border-soft);
    text-decoration: none;
    color: inherit;
    transition: background var(--duration-fast) var(--ease);
    position: relative;
}

.notif-item:last-child { border-bottom: none; }

.notif-item:hover { background: rgba(19, 120, 116, 0.04); }

.notif-item.unread::before {
    content: '';
    position: absolute;
    top: 14px;
    right: var(--space-4);
    width: 8px;
    height: 8px;
    background: var(--color-primary-500);
    border-radius: 50%;
}

.notif-item-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 2px;
    padding-right: 16px;
}

.notif-item-msg {
    font-size: 12px;
    color: var(--color-text-muted);
    line-height: 1.4;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.notif-item-time {
    font-size: 11px;
    color: var(--color-text-soft);
}

/* Content */
.content {
    flex: 1;
    padding: var(--space-6);
    max-width: var(--content-max);
    width: 100%;
    margin: 0 auto;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}

.page-header h1 {
    font-size: 24px;
}

.page-header p {
    color: var(--color-text-muted);
    font-size: 14px;
    margin-top: 4px;
}

/* Backdrop (mobile) */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(6, 47, 56, 0.5);
    backdrop-filter: blur(4px);
    z-index: 90;
    opacity: 0;
    transition: opacity var(--duration-base) var(--ease);
}

.sidebar-backdrop.show {
    opacity: 1;
}
