/**
 * App Layout - Shared Header & Sidebar Styles
 * Include this on all pages for consistent layout
 */

/* ========== APP LAYOUT STRUCTURE ========== */
.app-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* ========== APP HEADER ========== */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    height: 60px;
    flex-shrink: 0;
    z-index: 100;
}

.app-header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.app-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.app-logo-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.app-logo-text {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.app-header-center {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.app-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Header Icon Buttons */
.header-icon-button {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    position: relative;
}

.header-icon-button:hover {
    border-color: var(--accent);
    background: rgba(99, 102, 241, 0.1);
}

.header-icon-button .badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--danger);
    color: white;
    font-size: 10px;
    font-weight: 600;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-icon-button .badge:empty,
.header-icon-button .badge[data-count="0"] {
    display: none;
}

/* Header User Section */
.header-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    background: var(--bg-card);
    border-radius: 10px;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s;
}

.header-user:hover {
    border-color: var(--accent);
}

.header-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    color: white;
}

.header-user-info {
    display: flex;
    flex-direction: column;
}

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

.header-user-role {
    font-size: 11px;
    color: var(--text-muted);
}

/* Header Page Title */
.header-page-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-page-title .icon {
    font-size: 20px;
}

/* ========== APP BODY ========== */
.app-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ========== SIDEBAR ========== */
.app-sidebar {
    width: 56px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 0;
    gap: 2px;
    flex-shrink: 0;
    overflow: hidden;
}

.sidebar-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    position: relative;
    text-decoration: none;
    flex-shrink: 0;
}

/* Ensure clicks pass through to button */
.sidebar-icon * {
    pointer-events: none;
}

.sidebar-icon:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.sidebar-icon.active {
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent);
}

/* Sidebar Tooltips */
.sidebar-icon .tooltip {
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-left: 10px;
    padding: 6px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 12px;
    color: var(--text-primary);
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
    z-index: 1000;
    pointer-events: none;
}

.sidebar-icon:hover .tooltip {
    opacity: 1;
    visibility: visible;
}

/* Sidebar Divider & Spacer */
.sidebar-divider {
    width: 30px;
    height: 1px;
    background: var(--border);
    margin: 4px 0;
    flex-shrink: 0;
}

.sidebar-spacer {
    flex: 1;
    min-height: 4px;
}

/* Sidebar Badge */
.sidebar-icon .sidebar-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    background: var(--danger);
    color: white;
    font-size: 9px;
    font-weight: 600;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Sidebar Submenu */
.sidebar-menu-group {
    position: relative;
    flex-shrink: 0;
}

.sidebar-submenu {
    position: absolute;
    left: 100%;
    top: 0;
    margin-left: 8px;
    min-width: 180px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateX(-10px);
    transition: all 0.2s ease;
    z-index: 9999;
    overflow: hidden;
}

.sidebar-menu-group.open .sidebar-submenu {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateX(0);
}

.submenu-header {
    padding: 12px 16px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}

.sidebar-submenu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 14px;
    transition: all 0.15s;
    border-left: 3px solid transparent;
    pointer-events: auto;
    cursor: pointer;
}

.sidebar-submenu-item:hover {
    background: var(--bg-secondary);
    border-left-color: var(--accent);
}

.sidebar-submenu-item.active {
    background: rgba(99, 102, 241, 0.1);
    border-left-color: var(--accent);
    color: var(--accent);
}

.submenu-icon {
    font-size: 16px;
    width: 24px;
    text-align: center;
}

.submenu-label {
    flex: 1;
}

/* ========== MAIN CONTENT ========== */
.app-main {
    flex: 1;
    overflow-y: auto;
    background: var(--bg-primary);
}

/* ========== HEADER DATE ========== */
.header-date {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
}

.header-date-icon {
    font-size: 14px;
}

.header-date-text {
    color: var(--text-muted);
}

/* ========== CALCULATOR ========== */
.app-calculator {
    position: fixed;
    left: 70px;
    bottom: 20px;
    width: 240px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.2s ease;
}

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

.calc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 14px;
}

.calc-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.calc-close:hover {
    color: var(--text-primary);
}

.calc-display {
    padding: 16px;
    text-align: right;
    font-size: 28px;
    font-weight: 600;
    color: var(--text-primary);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    overflow: hidden;
    text-overflow: ellipsis;
}

.calc-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    padding: 12px;
}

.calc-btn {
    padding: 14px;
    font-size: 18px;
    font-weight: 500;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.15s;
}

.calc-btn:hover {
    background: var(--bg-card);
    border-color: var(--accent);
}

.calc-btn:active {
    transform: scale(0.95);
}

.calc-btn.operator {
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent);
    border-color: rgba(99, 102, 241, 0.3);
}

.calc-btn.operator:hover {
    background: rgba(99, 102, 241, 0.25);
}

.calc-btn.clear {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.3);
}

.calc-btn.clear:hover {
    background: rgba(239, 68, 68, 0.25);
}

.calc-btn.equals {
    grid-row: span 2;
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    color: white;
    border: none;
}

.calc-btn.equals:hover {
    opacity: 0.9;
}

.calc-btn.zero {
    grid-column: span 2;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
    .app-header {
        padding: 10px 15px;
    }

    .app-logo-text {
        display: none;
    }

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

    .header-user {
        padding: 6px;
    }

    .header-date-text {
        display: none;
    }

    .header-date {
        padding: 8px 10px;
    }

    .app-sidebar {
        width: 50px;
    }

    .sidebar-icon {
        width: 38px;
        height: 38px;
        font-size: 18px;
    }

    .app-calculator {
        left: 60px;
    }
}

@media (max-width: 480px) {
    .app-sidebar {
        display: none;
    }

    .app-header-center {
        display: none;
    }

    .header-date {
        display: none;
    }

    .app-calculator {
        left: 10px;
        right: 10px;
        width: auto;
        bottom: 10px;
    }
}
