/**
 * GOLDEN 99 - Foldable Device Optimization
 * Samsung Galaxy Z Flip 5
 */

/* Default: Main Screen */
body.view-main #main-screen { display: block; }
body.view-main #cover-screen { display: none; }
body.view-main #flex-screen { display: none; }

/* Cover Screen Mode */
body.view-cover #main-screen { display: none !important; }
body.view-cover #cover-screen { display: flex !important; }
body.view-cover #flex-screen { display: none !important; }

/* Flex Mode */
body.view-flex #main-screen { display: none !important; }
body.view-flex #cover-screen { display: none !important; }
body.view-flex #flex-screen { display: flex !important; }

/* ==================== COVER SCREEN ==================== */
#cover-screen {
    background: linear-gradient(135deg, #064E3B 0%, #059669 50%, #10B981 100%);
    color: white;
    padding: 20px;
    padding-top: calc(20px + env(safe-area-inset-top, 0));
    min-height: 100vh;
    display: flex; flex-direction: column;
    position: relative; overflow: hidden;
}

#cover-screen::before {
    content: '';
    position: absolute; top: -50%; right: -50%;
    width: 200%; height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    animation: coverRotate 30s linear infinite;
}
@keyframes coverRotate { from{transform:rotate(0deg)} to{transform:rotate(360deg)} }

.cover-header { text-align: center; margin-bottom: 20px; position: relative; z-index: 1; }
.cover-logo {
    font-size: 1.5rem; font-weight: 800; letter-spacing: 1px;
    text-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.cover-stats {
    display: grid; grid-template-columns: repeat(2, 1fr);
    gap: 10px; margin-bottom: 16px;
    position: relative; z-index: 1;}
.cover-stat {
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(20px);
    border-radius: var(--radius-lg);
    padding: 14px;
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    border: 1px solid rgba(255,255,255,0.2);
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    transition: transform 0.2s;
}
.cover-stat:active { transform: scale(0.95); }
.cover-stat .stat-value { font-size: 1.5rem; font-weight: 800; }
.cover-stat .stat-label { font-size: 0.7rem; opacity: 0.9; font-weight: 600; }

.cover-items {
    flex: 1;
    background: rgba(255,255,255,0.1);
    backdrop-filter: blur(20px);
    border-radius: var(--radius-lg);
    padding: 14px; margin-bottom: 16px;
    overflow-y: auto;
    border: 1px solid rgba(255,255,255,0.2);
    position: relative; z-index: 1;
}
.cover-item {
    display: flex; justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    font-size: 0.8rem; font-weight: 500;
}
.cover-item:last-child { border-bottom: none; }

.cover-actions { display: flex; gap: 10px; position: relative; z-index: 1; }
.cover-btn {
    flex: 1;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    padding: 16px;
    background: white; color: var(--md-primary);
    border: none; border-radius: var(--radius-full);
    font-family: inherit; font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    transition: all 0.2s var(--ease-spring);
}
.cover-btn:active { transform: scale(0.95); }

/* ==================== FLEX MODE ==================== */
#flex-screen {
    min-height: 100vh;    display: flex; flex-direction: column;
    background: var(--md-surface);
}

.flex-top {
    flex: 1; padding: 16px;
    display: flex; flex-direction: column; gap: 16px;
    background: linear-gradient(180deg, #D1FAE5 0%, var(--md-surface) 100%);
}
.flex-charts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mini-chart {
    height: 160px;
    background: var(--md-surface-glass);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--md-outline);
}

.flex-stats-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; }
.stat-pill {
    padding: 8px 16px;
    background: var(--md-surface-glass);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-full);
    font-size: 0.75rem; font-weight: 600;
    white-space: nowrap;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--md-outline);
}
.stat-pill.warning { background: #FEF3C7; color: #92400E; }
.stat-pill.critical { background: #FEE2E2; color: #991B1B; }

.flex-bottom {
    padding: 20px;
    background: var(--md-surface-glass-strong);
    backdrop-filter: blur(20px);
    border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
    box-shadow: var(--shadow-lg);
    border-top: 1px solid rgba(255,255,255,0.5);
}

.quick-form { display: flex; flex-direction: column; gap: 10px; }
.quick-form input {
    width: 100%; padding: 14px;
    border: 1.5px solid var(--md-outline);
    border-radius: var(--radius-md);
    font-family: inherit; font-size: 0.9rem;
    background: var(--md-surface-glass);
    outline: none;    transition: all 0.2s;
}
.quick-form input:focus { border-color: var(--md-primary); box-shadow: 0 0 0 3px var(--md-primary-container); }

/* Responsive Adjustments */
@media (max-width: 320px) {
    .cover-stats { gap: 8px; }
    .cover-stat { padding: 10px; }
    .cover-stat .stat-value { font-size: 1.25rem; }
    .cover-btn { padding: 12px; font-size: 0.8rem; }
}
@media (min-aspect-ratio: 1/1) and (max-height: 600px) {
    .flex-top { min-height: 45vh; }
    .flex-bottom { min-height: 55vh; }
}