/* ═══════════════════════════════════════════════════════════════
   HRIS SaaS — Layout (Topbar, Sidebar, Main Content)
   ═══════════════════════════════════════════════════════════════ */

/* ── App Shell ───────────────────────────────────────────── */
.app {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ── Top Navigation ──────────────────────────────────────── */
.topbar {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    height: var(--topbar-height);
    background: var(--bg-topbar);
    border-bottom: 1px solid var(--border-secondary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-6);
    z-index: var(--z-topbar);
    transition: left var(--transition-slow);
    backdrop-filter: blur(8px);
}

body.sidebar-collapsed .topbar {
    left: var(--sidebar-collapsed);
}

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

.topbar-search {
    position: relative;
    width: 320px;
}

.topbar-search .input {
    padding-left: 36px;
    background: var(--bg-surface-secondary);
    border-color: transparent;
    border-radius: var(--radius-lg);
}

.topbar-search .input:focus {
    background: var(--bg-input);
    border-color: var(--border-focus);
}

.topbar-search .search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    font-size: 16px;
}

.topbar-search .search-shortcut {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 11px;
    font-weight: var(--font-medium);
    color: var(--text-tertiary);
    background: var(--bg-surface);
    border: 1px solid var(--border-primary);
    padding: 1px 6px;
    border-radius: 4px;
}

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

.topbar-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    position: relative;
    font-size: 20px;
}

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

.topbar-btn .notification-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    background: var(--danger);
    border-radius: 50%;
    border: 2px solid var(--bg-topbar);
}

.user-menu {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 4px 8px 4px 4px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--transition-fast);
    border: none;
    background: none;
}

.user-menu:hover {
    background: var(--bg-surface-secondary);
}

.user-menu .user-info {
    text-align: right;
}

.user-menu .user-name {
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--text-primary);
    line-height: 1.2;
}

.user-menu .user-role {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
}

/* ── Sidebar ─────────────────────────────────────────────── */

/* ── Sidebar Custom Properties (dark slate theme) ── */
:root {
    --sidebar-bg: #0f1623;
    --sidebar-text: rgba(255, 255, 255, 0.85);
    --sidebar-text-muted: rgba(255, 255, 255, 0.40);
    --sidebar-text-label: rgba(255, 255, 255, 0.28);
    --sidebar-border: rgba(255, 255, 255, 0.07);
    --sidebar-hover-bg: rgba(255, 255, 255, 0.06);
    --sidebar-active-bg: rgba(255, 255, 255, 0.10);
    --sidebar-active-text: #ffffff;
    --sidebar-active-accent: #e11d48;
    --sidebar-toggle-bg: rgba(255, 255, 255, 0.10);
    --sidebar-toggle-border: rgba(255, 255, 255, 0.15);
    --sidebar-toggle-color: rgba(255, 255, 255, 0.70);
    --sidebar-scrollbar: rgba(255, 255, 255, 0.15);
}

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    z-index: var(--z-sidebar);
    display: flex;
    flex-direction: column;
    transition: width var(--transition-slow);
    overflow: hidden;
    box-shadow: 1px 0 0 rgba(255,255,255,0.04), 4px 0 20px rgba(0, 0, 0, 0.3);
}

body.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed);
}

.sidebar-header {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-4);
    border-bottom: 1px solid var(--sidebar-border);
    flex-shrink: 0;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    text-decoration: none;
}

.sidebar-logo .logo-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: var(--font-bold);
    font-size: var(--text-sm);
    flex-shrink: 0;
    padding: 2px;
    background: none;
    border: none;
}

.sidebar-logo .logo-text {
    font-size: 15px;
    font-weight: 700;
    color: var(--sidebar-text);
    letter-spacing: 0.06em;
    white-space: nowrap;
    text-transform: uppercase;
}

body.sidebar-collapsed .sidebar-logo .logo-text {
    display: none;
}

.sidebar-toggle {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--sidebar-toggle-bg);
    border: 1px solid var(--sidebar-toggle-border);
    color: var(--sidebar-toggle-color);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.sidebar-toggle:hover {
    background: var(--sidebar-hover-bg);
    color: var(--sidebar-text);
}

body.sidebar-collapsed .sidebar-toggle {
    transform: rotate(180deg);
}

.sidebar-nav {
    flex: 1;
    padding: var(--space-3) var(--space-2);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--sidebar-scrollbar) transparent;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--sidebar-scrollbar); border-radius: 4px; }

.nav-section-label {
    padding: var(--space-5) var(--space-2) var(--space-2);
    font-size: 10px;
    font-weight: 700;
    color: var(--sidebar-text-label);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    white-space: nowrap;
}

body.sidebar-collapsed .nav-section-label {
    text-align: center;
    font-size: 0;
}

body.sidebar-collapsed .nav-section-label::after {
    content: '—';
    font-size: 10px;
    color: var(--sidebar-text-label);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 9px 12px;
    margin: 1px 0;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--sidebar-text);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    white-space: nowrap;
    border: none;
    background: none;
    width: 100%;
    font-family: var(--font-family);
    text-align: left;
    outline: none;          /* remove browser focus ring */
}

.nav-item:focus-visible {
    outline: 2px solid var(--sidebar-active-accent);
    outline-offset: -2px;
}

.nav-item:hover {
    color: var(--sidebar-text);
    background: var(--sidebar-hover-bg);
}

.nav-item.active {
    color: #ffffff;
    background: rgba(225, 29, 72, 0.15);
    font-weight: 600;
    box-shadow: inset 3px 0 0 var(--sidebar-active-accent);
}

.nav-item .nav-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    color: var(--sidebar-text-muted);
    transition: color 0.2s;
}

.nav-item:hover .nav-icon {
    color: rgba(255, 255, 255, 0.9);
}

.nav-item.active .nav-icon {
    color: #ffffff;
}

.nav-item .nav-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

body.sidebar-collapsed .nav-item .nav-label {
    display: none;
}

.nav-item .nav-badge {
    font-size: 11px;
    font-weight: var(--font-semibold);
    background: rgba(255,255,255,0.25);
    color: #fff;
    padding: 1px 7px;
    border-radius: var(--radius-full);
    min-width: 18px;
    text-align: center;
}

body.sidebar-collapsed .nav-item .nav-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 8px;
    height: 8px;
    min-width: unset;
    padding: 0;
    font-size: 0;
    background: #ffed4a;
}

body.sidebar-collapsed .nav-item {
    justify-content: center;
    padding: 10px;
    position: relative;
}

/* Sub-items in dropdowns */
.nav-item.sub-item {
    padding: 7px 12px 7px 18px;
    font-size: 13px;
    min-height: 34px;
    margin: 1px 0;
    color: var(--sidebar-text-muted);
    font-weight: 400;
}

.nav-item.sub-item:hover {
    color: var(--sidebar-text);
    background: var(--sidebar-hover-bg);
    box-shadow: none;
}

.nav-item.sub-item.active {
    color: #ffffff;
    background: rgba(225, 29, 72, 0.15);
    font-weight: 600;
    box-shadow: inset 3px 0 0 var(--sidebar-active-accent);
}

/* Submenu vertical line */
.submenu::before {
    background: rgba(255, 255, 255, 0.15) !important;
}

/* Chevron icon in nav group */
.submenu-icon {
    color: rgba(255, 255, 255, 0.50) !important;
}
.nav-item:hover .submenu-icon {
    color: rgba(255, 255, 255, 0.85) !important;
}

/* ── Sidebar Footer ────────────────────────────────── */
.sidebar-footer {
    padding: var(--space-3) var(--space-2);
    border-top: 1px solid var(--sidebar-border);
    flex-shrink: 0;
}

/* Company Selector */
.company-selector {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 8px 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--transition-fast);
    border: none;
    background: var(--sidebar-hover-bg);
    width: 100%;
    text-align: left;
    outline: none;
}

.company-selector:hover {
    background: var(--sidebar-active-bg);
}

.company-logo {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    background: var(--sidebar-hover-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--sidebar-text);
    font-weight: var(--font-bold);
    font-size: var(--text-xs);
    flex-shrink: 0;
    border: 1px solid var(--sidebar-border);
    overflow: hidden;
}

.company-info {
    overflow: hidden;
}

.company-name {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--sidebar-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.company-plan {
    font-size: var(--text-xs);
    color: var(--sidebar-text-muted);
}

body.sidebar-collapsed .company-info {
    display: none;
}



/* ── Main Content ────────────────────────────────────────── */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    margin-top: var(--topbar-height);
    overflow-y: auto;
    transition: margin-left var(--transition-slow);
    height: calc(100vh - var(--topbar-height));
}

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

.page {
    padding: 24px 32px;
    max-width: 1400px;
    margin: 0 auto;
    min-height: 100vh;
    animation: page-fade-in 0.2s ease-out;
}

@keyframes page-fade-in {
    from {
        opacity: 0;
        transform: translateY(4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.page-header-left {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.page-title {
    font-size: var(--text-2xl);
    font-weight: var(--font-bold);
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

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

.page-header-right {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-shrink: 0;
}

/* Section */
.section {
    margin-bottom: var(--space-6);
}

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

.section-title {
    font-size: var(--text-lg);
    font-weight: var(--font-semibold);
    color: var(--text-primary);
}

/* ── Mobile Overlay ──────────────────────────────────────── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--bg-modal-overlay);
    z-index: calc(var(--z-sidebar) - 1);
}

.mobile-menu-btn {
    display: none;
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    border-radius: var(--radius-md);
    font-size: 22px;
}

/* ── CHERRYAPS Legacy Form Classes ──────────────────────── */
/* Colors and dark mode styles defined in css/responsive.css */
/* Only structural/layout properties kept here */

.CHERRYAPS-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--space-6);
}

.CHERRYAPS-form-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-6);
    border-bottom: 1px solid var(--border-primary);
    padding-bottom: 16px;
}

.CHERRYAPS-breadcrumb {
    font-size: 14px;
    margin-bottom: 8px;
}


.CHERRYAPS-form-title {
    font-size: 14px;
    margin-bottom: 16px;
}

.CHERRYAPS-btn-back {
    padding: 8px 16px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
}

.CHERRYAPS-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.CHERRYAPS-input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.CHERRYAPS-btn-submit {
    padding: 10px 24px;
    border-radius: 6px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.CHERRYAPS-btn-badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    margin-left: 8px;
    vertical-align: middle;
}

.CHERRYAPS-wysiwyg-content {
    flex: 1;
    padding: 12px;
}


/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 1024px) {
    .topbar-search {
        width: 240px;
    }

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

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        box-shadow: none;
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
        box-shadow: var(--shadow-xl);
    }

    body.sidebar-open .sidebar-overlay {
        display: block;
    }

    .topbar {
        left: 0 !important;
    }

    .main-content {
        margin-left: 0 !important;
    }

    .mobile-menu-btn {
        display: flex;
    }

    .topbar-search {
        display: none;
    }

    .user-menu .user-info {
        display: none;
    }

    .page {
        padding: var(--space-4);
    }

    .page-header {
        flex-direction: column;
        gap: var(--space-3);
    }

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

    .page-header-right .btn {
        flex: 1;
    }

    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
    }

    .tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .data-table {
        font-size: var(--text-xs);
    }
}

@media (max-width: 480px) {
    :root {
        --topbar-height: 52px;
    }

    .page {
        padding: var(--space-3);
    }

    .card-body {
        padding: var(--space-4);
    }
}