/**
 * app-layout.css - Layout & Page Components
 * Sidebar text nav + full-width content
 */

/* ===== SHELL ===== */

.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    position: relative;
    z-index: 1;
}

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

.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: rgba(13, 26, 38, 0.85);
    backdrop-filter: blur(20px) saturate(1.4);
    -webkit-backdrop-filter: blur(20px) saturate(1.4);
    border-bottom: 1px solid var(--border-color);
    z-index: 9999;
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 8px;
}

.app-header-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    font-size: 1.1rem;
    color: var(--text-primary);
    text-decoration: none;
    letter-spacing: -0.03em;
    margin-right: 16px;
    white-space: nowrap;
}

.app-header-logo-svg {
    height: 28px;
    width: auto;
    flex-shrink: 0;
}

.app-header-logo-text {
    /* keep text alongside logo */
}

.app-header-logo:hover { color: var(--text-primary); }

.app-header-nav {
    display: flex;
    align-items: center;
    gap: 4px;
}

.app-header-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.9rem;
    border-radius: var(--radius-md);
    transition: all 0.15s ease;
}

.app-header-link i { font-size: 1.1em; }

.app-header-link:hover {
    color: var(--text-primary);
    background: rgba(255,255,255,0.04);
}

.app-header-link.active {
    color: var(--accent);
    background: var(--accent-bg);
}

.app-header-spacer { flex: 1; }

/* Tokens pill */
.app-header-tokens {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 6px 5px 14px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    margin-right: 12px;
    font-size: 0.875rem;
}

.app-header-tokens .token-balance {
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--text-primary);
}

.app-header-tokens .token-label {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.app-header-tokens .token-buy-link {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    background: var(--accent-gradient);
    color: #fff;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 700;
    text-decoration: none;
    transition: all 0.15s ease;
}

.app-header-tokens .token-buy-link:hover {
    box-shadow: var(--shadow-glow-sm);
    transform: translateY(-1px);
}

/* Tokens icon */
.app-header-tokens > i { color: var(--text-muted); font-size: 1rem; }

/* User */
.app-header-user {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.9rem;
}

.app-header-icon-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    text-decoration: none;
    transition: all 0.15s ease;
    font-size: 1.1rem;
}

.app-header-icon-link:hover {
    color: var(--text-primary);
    background: rgba(255,255,255,0.04);
}

.app-header-icon-link.active {
    color: var(--accent);
    background: var(--accent-bg);
}

.app-header-user a.btn-primary { color: #fff; }
.app-header-user a.btn-primary:hover { color: #fff; }

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

.app-main {
    display: flex;
    flex: 1;
    margin-top: 56px;
}

/* ===== SIDEBAR — text nav ===== */

.app-sidebar {
    width: 220px;
    flex-shrink: 0;
    position: fixed;
    top: 56px;
    bottom: 0;
    left: 0;
    background: var(--bg-primary);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    z-index: 100;
    padding: 20px 0;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
}

.sidebar-section {
    padding: 0 12px;
}

.sidebar-section-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    padding: 0 12px 10px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    margin-bottom: 2px;
    border-radius: var(--radius-md);
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 0.925rem;
    font-weight: 500;
    transition: all 0.15s ease;
    gap: 8px;
}

.sidebar-link:hover {
    color: var(--text-primary);
    background: rgba(255,255,255,0.03);
}

.sidebar-link.active {
    color: var(--accent);
    background: var(--accent-bg);
    font-weight: 600;
}

.sidebar-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background: var(--accent);
    border-radius: 0 3px 3px 0;
}

.sidebar-link {
    position: relative;
}

.sidebar-link-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-link-badge {
    font-size: 0.7rem;
    font-weight: 600;
    font-family: var(--font-mono);
    color: var(--text-muted);
    background: rgba(255,255,255,0.04);
    padding: 2px 8px;
    border-radius: var(--radius-full);
    white-space: nowrap;
    flex-shrink: 0;
}

.sidebar-link.active .sidebar-link-badge {
    color: var(--accent);
    background: rgba(79,143,255,0.12);
}

.sidebar-link-badge.free {
    color: var(--success);
    background: var(--success-bg);
}

/* ===== CONTENT — full width ===== */

.app-content {
    flex: 1;
    margin-left: 220px;
    padding: 40px 48px 60px;
    min-height: calc(100vh - 56px);
    min-width: 0; /* prevent overflow */
}

/* ===== PAGE TITLE (replaces app-window) ===== */

.app-window {
    background: transparent;
    border: none;
    max-width: none;
    margin: 0;
}

.app-window-titlebar {
    display: flex;
    align-items: baseline;
    padding: 0;
    margin-bottom: 32px;
    background: transparent;
    height: auto;
    border-bottom: none;
    gap: 16px;
}

.app-window-title {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.03em;
    line-height: 1.2;
}

.app-window-content {
    padding: 0;
}

/* Sized windows = card (login, register, modals) */
.app-window-sm, .app-window-md, .app-window-lg, .app-window-xl {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.app-window-sm .app-window-titlebar,
.app-window-md .app-window-titlebar,
.app-window-lg .app-window-titlebar,
.app-window-xl .app-window-titlebar {
    padding: 20px 28px;
    margin-bottom: 0;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-surface-hover);
}

.app-window-sm .app-window-title,
.app-window-md .app-window-title,
.app-window-lg .app-window-title,
.app-window-xl .app-window-title {
    font-size: 1.15rem;
}

.app-window-sm .app-window-content,
.app-window-md .app-window-content,
.app-window-lg .app-window-content,
.app-window-xl .app-window-content {
    padding: 28px;
}

.app-window-sm { max-width: 440px; margin: 60px auto; }
.app-window-md { max-width: 540px; margin: 60px auto; }
.app-window-lg { max-width: 700px; margin: 40px auto; }
.app-window-xl { max-width: 880px; margin: 40px auto; }

/* ===== PANELS ===== */

.app-panel {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
}

.app-panel:hover { border-color: var(--border-color-light); }

.app-panel-header {
    margin: 0 0 16px;
    font-size: 1.05rem;
    font-weight: 700;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 14px;
}

.app-panel-success { background: var(--success-bg); border-color: var(--success-border); }
.app-panel-warning { background: var(--warning-bg); border-color: var(--warning-border); }
.app-panel-error { background: var(--error-bg); border-color: var(--error-border); }
.app-panel-info { background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: var(--radius-lg); }

/* ===== BALANCE ===== */

.app-balance {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 36px;
    margin-bottom: 28px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.app-balance::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 50% 0%, var(--accent-bg), transparent 70%);
    pointer-events: none;
}

.app-balance-value { font-size: 3.5rem; font-weight: 800; position: relative; }
.app-balance-label { font-size: 0.95rem; color: var(--text-muted); position: relative; }

/* ===== DATA / STATS ===== */

.app-data-grid {
    display: grid;
    grid-template-columns: 150px 1fr;
    gap: 12px 24px;
    font-size: 1rem;
    color: var(--text-secondary);
}

.app-data-label { font-weight: 650; color: var(--text-primary); }

.app-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 16px;
}

.app-stats-card {
    text-align: center;
    padding: 24px 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    transition: all 0.2s ease;
}

.app-stats-card:hover { border-color: var(--border-color-light); transform: translateY(-2px); }
.app-stats-value { font-size: 2rem; font-weight: 800; }
.app-stats-label { font-size: 0.85rem; color: var(--text-muted); margin-top: 6px; }

.app-links-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.app-link-card {
    padding: 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    text-align: center;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 550;
    transition: all 0.2s ease;
}

.app-link-card:hover {
    background: var(--bg-surface-hover);
    color: var(--accent);
    border-color: var(--accent-border);
}

/* ===== FORMS ===== */

.app-form-group { margin-bottom: 20px; }
.app-form-label { display: block; margin-bottom: 8px; font-weight: 600; font-size: 0.9rem; color: var(--text-secondary); }
.app-form-hint { font-size: 0.85rem; color: var(--text-muted); margin-top: 6px; }

.app-badge-verified { color: var(--success); margin-left: 6px; }
.app-badge-warning { color: var(--warning); margin-left: 6px; }

.app-icon-xl { font-size: 56px; margin-bottom: 20px; }
.app-icon-lg { font-size: 40px; margin-bottom: 16px; }

/* ===== DROP ZONE ===== */

.app-drop-zone {
    border: 2px dashed var(--border-color-light);
    border-radius: var(--radius-xl);
    padding: 60px 24px;
    text-align: center;
    cursor: pointer;
    margin-bottom: 24px;
    color: var(--text-muted);
    transition: all 0.25s ease;
}

.app-drop-zone:hover {
    background: var(--bg-surface);
    border-color: var(--accent);
    box-shadow: inset 0 0 60px var(--accent-bg);
}

.app-drop-zone.highlight {
    border-color: var(--success);
    background: var(--success-bg);
}

/* ===== MODAL ===== */

.app-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(13, 26, 38, 0.8);
    backdrop-filter: blur(8px);
    z-index: 10000;
    justify-content: center;
    align-items: center;
}

.app-modal-overlay.active { display: flex; }

.app-modal-overlay .app-window {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    max-width: 90vw;
}

.app-modal-overlay .app-window-titlebar {
    padding: 18px 24px;
    margin-bottom: 0;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-surface-hover);
}

.app-modal-overlay .app-window-title { font-size: 1.05rem; }
.app-modal-overlay .app-window-content { padding: 28px; }

/* Alert modal (global appModal) */
#app-alert-modal .app-window { width: 420px; min-width: 280px; }
#app-alert-modal .app-alert-icon { font-size: 1.6rem; margin-bottom: 12px; }
#app-alert-modal .app-alert-icon.error { color: var(--color-danger, #e74c3c); }
#app-alert-modal .app-alert-icon.success { color: var(--color-success, #2ecc71); }
#app-alert-modal .app-alert-icon.warning { color: var(--color-warning, #f39c12); }
#app-alert-modal .app-alert-icon.info { color: var(--color-info, #3498db); }
#app-alert-modal .app-alert-message { color: var(--text-secondary); line-height: 1.6; white-space: pre-line; word-break: break-word; }
#app-alert-modal .app-alert-actions { margin-top: 24px; display: flex; justify-content: flex-end; gap: 10px; }
#app-alert-modal .app-alert-actions .btn { min-width: 80px; }

/* ===== PACKAGES ===== */

.app-packages-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.app-package-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 28px 20px;
    text-align: center;
    position: relative;
    cursor: pointer;
    transition: all 0.25s ease;
}

.app-package-card:hover {
    border-color: var(--border-color-light);
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.app-package-card--popular {
    background: linear-gradient(180deg, rgba(79,143,255,0.06), var(--bg-surface));
    border-color: var(--accent-border);
}

.app-package-badge {
    position: absolute;
    top: -11px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent-gradient);
    color: #fff;
    padding: 4px 16px;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: var(--radius-full);
    letter-spacing: 0.06em;
    box-shadow: var(--shadow-glow-sm);
}

.app-package-name { font-size: 1.1rem; font-weight: 700; margin-bottom: 6px; }
.app-package-tokens { font-size: 2.75rem; font-weight: 800; margin: 16px 0; background: var(--accent-gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.app-package-details { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 6px; }
.app-package-price { font-size: 1.25rem; font-weight: 750; margin-bottom: 4px; }
.app-package-unit { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 12px; }

.app-package-card--selected {
    border-color: var(--accent);
    border-width: 2px;
    background: var(--accent-bg);
    box-shadow: var(--shadow-glow);
}

.app-package-card--selected.app-package-card--popular { background: var(--accent-bg); }

.app-package-select-indicator {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 24px;
    height: 24px;
    border: 2px solid var(--border-color-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    color: transparent;
    background: var(--bg-surface);
    transition: all 0.15s ease;
}

.app-package-card--selected .app-package-select-indicator {
    border-color: var(--accent);
    background: var(--accent-gradient);
    color: white;
    box-shadow: var(--shadow-glow-sm);
}

/* ===== SPECIAL ACCESS ===== */

.app-special-access-box {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    background: var(--info-bg);
    border: 1px dashed rgba(129,140,248,0.2);
    padding: 28px;
    margin-bottom: 32px;
    border-radius: var(--radius-xl);
}

.app-special-access-icon { font-size: 36px; flex-shrink: 0; }
.app-special-access-content { flex: 1; }
.app-special-access-content strong { display: block; font-size: 1.05rem; margin-bottom: 8px; }
.app-special-access-content p { margin: 0 0 14px; font-size: 0.95rem; color: var(--text-secondary); line-height: 1.6; }

/* ===== PURCHASE ===== */

.app-purchase-section {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 28px;
    margin-bottom: 32px;
}

.app-purchase-section .app-promo-form { display: flex; gap: 12px; align-items: center; margin-bottom: 20px; }

.app-business-option {
    margin-bottom: 20px;
    padding: 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.app-business-option .app-checkbox-label { display: flex; align-items: center; gap: 12px; cursor: pointer; margin: 0; color: var(--text-secondary); font-size: 0.95rem; }

.app-buy-button {
    width: 100%;
    padding: 18px 32px;
    font-size: 1.1rem;
    font-weight: 750;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-radius: var(--radius-lg);
}

.app-buy-button:disabled { opacity: 0.3; }

/* Token balance display */
.app-token-balance { text-align: center; margin-bottom: 32px; }
.app-token-balance-label { font-size: 0.95rem; color: var(--text-muted); }
.app-token-balance-value { font-size: 3.5rem; font-weight: 800; background: var(--accent-gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }

/* ===== MISC COMPONENTS ===== */

.app-promo-section { background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: var(--radius-lg); padding: 20px; margin-bottom: 20px; }
.app-promo-form { display: flex; gap: 12px; align-items: center; }
.app-promo-label { font-weight: 600; white-space: nowrap; color: var(--text-secondary); }
.app-promo-result { margin-top: 10px; font-size: 0.9rem; display: none; }
.app-checkbox-label { display: flex; align-items: center; gap: 12px; cursor: pointer; color: var(--text-secondary); }
.app-info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; font-size: 0.95rem; color: var(--text-secondary); }

.app-checkout-overlay { display: none; position: fixed; inset: 0; background: rgba(13, 26, 38, 0.8); backdrop-filter: blur(8px); z-index: 10000; justify-content: center; align-items: center; }
.app-checkout-overlay.active { display: flex; }
.app-checkout-modal { background: var(--bg-surface); padding: 48px; border: 1px solid var(--border-color); border-radius: var(--radius-xl); text-align: center; box-shadow: var(--shadow-lg); }
.app-checkout-message { margin-bottom: 16px; font-weight: 600; font-size: 1.05rem; }
.app-checkout-wait { font-size: 1.5rem; color: var(--text-muted); }

.app-footer-info { text-align: center; margin-top: 28px; font-size: 0.85rem; color: var(--text-muted); }
.app-footer-info a { color: var(--accent); }
.app-footer-info p { margin: 6px 0; }

/* EXIF table */
.app-exif-table { background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: var(--radius-lg); overflow: hidden; }
.app-exif-row { display: flex; border-bottom: 1px solid var(--border-color); }
.app-exif-row:last-child { border-bottom: none; }
.app-exif-label { width: 180px; padding: 12px 16px; background: var(--bg-surface-hover); font-weight: 650; flex-shrink: 0; }
.app-exif-value { flex: 1; padding: 12px 16px; color: var(--text-secondary); }
.app-exif-empty { padding: 28px; text-align: center; color: var(--text-muted); }

.app-image-preview { max-width: 300px; max-height: 200px; border: 1px solid var(--border-color); border-radius: var(--radius-md); }
.app-gps-section { margin-top: 24px; }
.app-gps-title { font-size: 1.05rem; font-weight: 650; margin-bottom: 12px; }
.app-gps-coords { font-size: 0.95rem; margin-bottom: 12px; color: var(--text-secondary); font-family: var(--font-mono); }
.app-content-wrapper { max-width: 860px; margin: 0 auto; }
.app-section-header { font-size: 1.05rem; font-weight: 650; margin-bottom: 16px; border-bottom: 1px solid var(--border-color); padding-bottom: 12px; }

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

.app-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40px;
    background: rgba(6,8,15,0.8);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--border-color);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    gap: 12px;
    color: var(--text-muted);
}

.app-footer a {
    color: var(--text-muted);
    text-decoration: none;
}

.app-footer a:hover { color: var(--text-secondary); }
.app-footer .sep { color: var(--border-color-strong); }

/* Keep old class compat */
.app-footer-separator { color: var(--border-color-strong); }
.app-dock { display: none; } /* old dock hidden if template still references it */

/* ===== RESPONSIVE ===== */

@media (max-width: 900px) {
    .app-sidebar { width: 180px; }
    .app-content { margin-left: 180px; padding: 32px 24px 48px; }
    .sidebar-link { font-size: 0.875rem; padding: 9px 12px; }
}

@media (max-width: 640px) {
    .app-sidebar {
        position: fixed;
        bottom: 40px;
        left: 0;
        right: 0;
        top: auto;
        width: 100%;
        height: auto;
        max-height: 50vh;
        border-right: none;
        border-top: 1px solid var(--border-color);
        flex-direction: row;
        padding: 12px 0;
        display: none; /* toggled via JS if needed */
    }

    .app-content {
        margin-left: 0;
        padding: 24px 16px 48px;
    }

    .app-header-nav { display: none; }
    .app-header { padding: 0 16px; }
}
