/* ===================================
   Google Dashboard - Dark Theme Styles
   Optimized for TV Display
   =================================== */

:root {
    /* Dark Theme Colors */
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --border-color: #30363d;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --accent-blue: #58a6ff;
    --accent-green: #3fb950;
    --accent-orange: #d29922;
    --accent-red: #f85149;
    --accent-purple: #a371f7;

    /* Spacing */
    --gap: 16px;
    --radius: 12px;
    --header-height: 60px;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
}

/* Light Theme Override */
body.light-theme {
    --bg-primary: #ffffff;
    --bg-secondary: #f6f8fa;
    --bg-tertiary: #eaeef2;
    --border-color: #d0d7de;
    --text-primary: #1f2328;
    --text-secondary: #656d76;
    --text-muted: #8c959f;
}

/* Reset & Base */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
}

/* ===================================
   Header
   =================================== */
.dashboard-header {
    height: var(--header-height);
    padding: 0 24px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    z-index: 100;
}

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

.dashboard-header h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

.live-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--accent-green);
    padding: 4px 10px;
    background: rgba(63, 185, 80, 0.15);
    border-radius: 20px;
}

.pulse {
    width: 8px;
    height: 8px;
    background: var(--accent-green);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.5;
        transform: scale(1.2);
    }
}

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

.clock {
    font-size: 32px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
}

.refresh-info {
    font-size: 13px;
    color: var(--text-secondary);
}

.settings-btn,
.fullscreen-btn {
    width: 40px;
    height: 40px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 20px;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.settings-btn:hover,
.fullscreen-btn:hover {
    background: var(--border-color);
    transform: scale(1.05);
}

/* ===================================
   Dashboard Grid
   =================================== */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: var(--gap);
    padding: var(--gap);
    height: calc(100vh - var(--header-height));
}

/* ===================================
   Dashboard Sections
   =================================== */
.dashboard-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all var(--transition-normal);
}

.dashboard-section:hover {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 1px var(--accent-blue);
}

.section-header {
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.section-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.section-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.last-refresh {
    font-size: 12px;
    color: var(--text-muted);
}

.refresh-btn {
    width: 28px;
    height: 28px;
    background: transparent;
    border: none;
    font-size: 14px;
    cursor: pointer;
    border-radius: 6px;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.refresh-btn:hover {
    background: var(--border-color);
}

.refresh-btn.refreshing {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.section-content {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.section-content iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: var(--bg-primary);
}

/* Hide headers mode */
body.hide-headers .section-header {
    display: none;
}

/* ===================================
   Placeholder
   =================================== */
.placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    background: var(--bg-primary);
    color: var(--text-secondary);
}

.placeholder.hidden {
    display: none;
}

.placeholder-icon {
    font-size: 64px;
    opacity: 0.3;
}

.placeholder p {
    font-size: 16px;
}

.setup-btn {
    padding: 10px 24px;
    background: var(--accent-blue);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.setup-btn:hover {
    background: #4c9aed;
    transform: translateY(-2px);
}

/* ===================================
   Modal
   =================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    width: 90%;
    max-width: 600px;
    max-height: 85vh;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    transform: scale(0.9) translateY(20px);
    transition: transform var(--transition-normal);
}

.modal-overlay.active .modal {
    transform: scale(1) translateY(0);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 20px;
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    font-size: 24px;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 6px;
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.modal-content {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* ===================================
   Tabs
   =================================== */
.settings-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
}

.tab-btn {
    padding: 8px 16px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 6px;
    transition: all var(--transition-fast);
}

.tab-btn:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.tab-btn.active {
    color: var(--accent-blue);
    background: rgba(88, 166, 255, 0.15);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ===================================
   Form Elements
   =================================== */
.setting-group {
    margin-bottom: 20px;
}

.setting-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.setting-group h3 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-secondary);
}

.help-link {
    font-size: 12px;
    color: var(--accent-blue);
    text-decoration: none;
    margin-left: 8px;
}

.help-link:hover {
    text-decoration: underline;
}

input[type="url"],
input[type="text"],
select {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

input[type="url"]:focus,
input[type="text"]:focus,
select:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.2);
}

input::placeholder {
    color: var(--text-muted);
}

.setting-hint {
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-muted);
}

/* Toggle Switch */
.toggle-label {
    display: flex !important;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.toggle-label input[type="checkbox"] {
    display: none;
}

.toggle-switch {
    width: 48px;
    height: 26px;
    background: var(--bg-tertiary);
    border-radius: 13px;
    position: relative;
    transition: all var(--transition-fast);
}

.toggle-switch::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    background: var(--text-secondary);
    border-radius: 50%;
    transition: all var(--transition-fast);
}

.toggle-label input:checked+.toggle-switch {
    background: var(--accent-blue);
}

.toggle-label input:checked+.toggle-switch::after {
    left: 25px;
    background: white;
}

/* Refresh Grid */
.refresh-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.refresh-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.refresh-item span {
    font-size: 14px;
}

.refresh-item select {
    width: auto;
    padding: 6px 10px;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-primary {
    background: var(--accent-blue);
    color: white;
}

.btn-primary:hover {
    background: #4c9aed;
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--border-color);
}

/* ===================================
   Help Modal
   =================================== */
.modal-help {
    max-width: 500px;
}

.modal-help .modal-content {
    font-size: 14px;
    line-height: 1.7;
}

.modal-help ol {
    padding-left: 20px;
    margin: 12px 0;
}

.modal-help li {
    margin-bottom: 8px;
}

.modal-help code {
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'SF Mono', Consolas, monospace;
    font-size: 13px;
}

/* ===================================
   Toast Notification
   =================================== */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 14px 28px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
    z-index: 2000;
}

.toast.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.toast.success {
    border-color: var(--accent-green);
}

.toast.error {
    border-color: var(--accent-red);
}

.toast-message {
    font-size: 14px;
    font-weight: 500;
}

/* ===================================
   Loading State
   =================================== */
.loading {
    position: relative;
}

.loading::after {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===================================
   Responsive Adjustments
   =================================== */
@media (max-width: 1200px) {
    .dashboard-header h1 {
        font-size: 20px;
    }

    .clock {
        font-size: 24px;
    }

    .section-header h2 {
        font-size: 16px;
    }
}

@media (max-width: 768px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
        grid-template-rows: repeat(4, 1fr);
    }

    .header-right {
        gap: 12px;
    }

    .refresh-info {
        display: none;
    }
}

/* ===================================
   Fullscreen Optimizations
   =================================== */
:fullscreen {
    background: var(--bg-primary);
}

:fullscreen .dashboard-header {
    display: none;
}

:fullscreen .dashboard-grid {
    height: 100vh;
}

/* TV Display Mode - Hide unnecessary UI */
body.tv-mode .settings-btn,
body.tv-mode .fullscreen-btn,
body.tv-mode .refresh-btn,
body.tv-mode .setup-btn {
    display: none;
}

body.tv-mode .section-controls {
    display: none;
}