/* ===========================
   Shell Layout Styles - Flat Design
   =========================== */

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

:root {
    /* Brand Colors */
    --primary-color: #163967;
    --primary-dark: #12306a;
    --primary-light: #12306a;
    --secondary-color: #10b981;
    --accent-color: #f59e0b;
    
    /* Neutral Colors */
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-light: #9ca3af;
    --border-color: #e5e7eb;
    
    /* Spacing */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    
    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    
    /* Safe Area Insets */
    --safe-area-top: env(safe-area-inset-top);
    --safe-area-bottom: env(safe-area-inset-bottom);
    
    /* Fixed Heights */
    --top-bar-height: 56px;
    --bottom-nav-height: 60px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

[x-cloak] {
    display: none !important;
}

#app {
    height: 100vh;
    width: 100vw;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ===========================
   Top Bar
   =========================== */

.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: calc(var(--top-bar-height) + var(--safe-area-top));
    background: var(--primary-color);
    color: white;
    z-index: 1000;
    padding-top: var(--safe-area-top);
}

.top-bar-content {
    height: var(--top-bar-height);
    display: flex;
    align-items: center;
    padding: 0 var(--spacing-md);
    gap: var(--spacing-md);
}

.menu-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    color: white;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: background 0.2s ease;
    flex-shrink: 0;
}

.menu-btn:active {
    background: rgba(255, 255, 255, 0.1);
}

.brand-name {
    flex: 1;
    min-width: 0;
}

.brand-name h1 {
    font-size: 18px;
    font-weight: 700;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.top-actions {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

/* ===========================
   Side Menu
   =========================== */

.menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1500;
    display: none;
}

.menu-overlay[style*="display: none"] {
    display: none !important;
}

.menu-overlay[x-show] {
    display: block;
}

.side-menu {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    max-width: 85vw;
    background: var(--bg-primary);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
}

.side-menu.menu-open {
    transform: translateX(0);
}

.menu-header {
    height: calc(var(--top-bar-height) + var(--safe-area-top));
    padding-top: var(--safe-area-top);
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-left: var(--spacing-md);
    padding-right: var(--spacing-md);
    flex-shrink: 0;
}

.menu-brand {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: 18px;
    font-weight: 700;
}

.menu-brand i {
    font-size: 24px;
}

.close-menu-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    color: white;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
}

.close-menu-btn:active {
    background: rgba(255, 255, 255, 0.1);
}

.menu-nav {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-md);
}

.menu-section {
    margin-bottom: var(--spacing-lg);
}

.menu-section-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-sm);
    padding: 0 var(--spacing-sm);
}

.menu-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: 12px var(--spacing-sm);
    color: var(--text-primary);
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: background 0.2s ease;
    font-size: 15px;
    margin-bottom: 2px;
}

.menu-item:active {
    background: var(--bg-secondary);
}

.menu-item i {
    width: 20px;
    text-align: center;
    color: var(--text-secondary);
}

.menu-item span {
    flex: 1;
}

/* ===========================
   Content Area (iframe)
   =========================== */

.content-area {
    flex: 1;
    position: relative;
    margin-top: calc(var(--top-bar-height) + var(--safe-area-top));
    margin-bottom: calc(var(--bottom-nav-height) + var(--safe-area-bottom));
    overflow: hidden;
}

.content-iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
    background: var(--bg-secondary);
}

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===========================
   Bottom Navigation Bar
   =========================== */

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--bottom-nav-height) + var(--safe-area-bottom));
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-around;
    align-items: flex-start;
    padding-top: var(--spacing-sm);
    padding-bottom: calc(var(--spacing-sm) + var(--safe-area-bottom));
    z-index: 1000;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: none;
    border: none;
    padding: var(--spacing-sm);
    cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.2s ease;
    flex: 1;
    max-width: 100px;
    min-width: 60px;
    position: relative;
}

.nav-item i {
    font-size: 22px;
}

.nav-item span {
    font-size: 11px;
    font-weight: 500;
}

.nav-item.active {
    color: var(--primary-color);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 32px;
    height: 3px;
    background: var(--primary-color);
    border-radius: 0 0 3px 3px;
}

/* Active state for touch */
.nav-item:active {
    opacity: 0.6;
}

/* ===========================
   Responsive Adjustments
   =========================== */

@media (max-width: 480px) {
    .brand-name h1 {
        font-size: 16px;
    }
    
    .nav-item i {
        font-size: 20px;
    }
    
    .nav-item span {
        font-size: 10px;
    }
}

@media (min-width: 768px) {
    .side-menu {
        width: 320px;
    }
    
    .nav-item {
        max-width: 120px;
    }
}

/* ===========================
   Accessibility
   =========================== */

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ===========================
   Touch Improvements
   =========================== */

@media (hover: none) {
    .menu-btn:hover,
    .close-menu-btn:hover,
    .menu-item:hover,
    .nav-item:hover {
        background: inherit;
        color: inherit;
    }
}

/* Improve tap targets on mobile */
@media (max-width: 768px) {
    .menu-btn,
    .close-menu-btn {
        min-width: 44px;
        min-height: 44px;
    }
    
    .menu-item {
        min-height: 44px;
    }
    
    .nav-item {
        min-height: 48px;
    }
}