:root {
    /* Glassmorphism Variables */
    --glass-bg: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.2);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.8);
    
    /* Colors */
    --primary-color: #3b82f6; /* Blue */
    --secondary-color: #64748b; /* Slate */
    --success-color: #10b981; /* Green */
    --warning-color: #eab308; /* Yellow */
    --danger-color: #ef4444; /* Red */
    
    /* App current state colors - Default to normal */
    --current-bg: var(--primary-config-bg, #0f172a); /* Theme Dark Default */
    
    /* Transitions */
    --transition-fast: 0.2s ease;
    --transition-smooth: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light Theme Overrides */
.theme-light {
    --glass-bg: rgba(255, 255, 255, 0.4);
    --glass-border: rgba(255, 255, 255, 0.6);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --current-bg: var(--primary-config-bg, #f8fafc);
}

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

body {
    font-family: 'Inter', sans-serif;
    color: var(--text-primary);
    background-color: var(--current-bg);
    min-height: 100vh;
    overflow: hidden;
    position: relative;
    transition: background-color var(--transition-smooth), color var(--transition-smooth);
}

/* Dynamic State Colors for the Background */
body.state-warning {
    --current-bg: #854d0e; /* Dark Yellow/Orange */
}
body.theme-light.state-warning {
    --current-bg: #fef08a; /* Light Yellow */
}

body.state-danger {
    --current-bg: #7f1d1d; /* Dark Red */
    animation: pulse-danger 2s infinite;
}
body.theme-light.state-danger {
    --current-bg: #fca5a5; /* Light Red */
    animation: pulse-danger-light 2s infinite;
}

@keyframes pulse-danger {
    0% { background-color: #7f1d1d; }
    50% { background-color: #991b1b; }
    100% { background-color: #7f1d1d; }
}

@keyframes pulse-danger-light {
    0% { background-color: #fca5a5; }
    50% { background-color: #f87171; }
    100% { background-color: #fca5a5; }
}

/* Background Animated Shapes for Glassmorphism Effect */
.bg-pattern {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    z-index: -1;
    opacity: 0.6;
    animation: float 20s infinite alternate cubic-bezier(0.4, 0, 0.2, 1);
}

.shape-1 {
    width: 40vw; height: 40vw;
    background: #3b82f6;
    top: -10vw; left: -10vw;
}
.shape-2 {
    width: 35vw; height: 35vw;
    background: #8b5cf6;
    bottom: -10vw; right: -5vw;
    animation-delay: -5s;
}
.shape-3 {
    width: 30vw; height: 30vw;
    background: #10b981;
    bottom: 20%; left: 10%;
    animation-delay: -10s;
}

.theme-light .shape-1 { background: #93c5fd; }
.theme-light .shape-2 { background: #c4b5fd; }
.theme-light .shape-3 { background: #6ee7b7; }

body.state-warning .shape-2, body.state-warning .shape-3 { background: #ca8a04; }
body.state-danger .shape-1, body.state-danger .shape-2, body.state-danger .shape-3 { background: #dc2626; }

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(5%, 5%) scale(1.1); }
    100% { transform: translate(-5%, -5%) scale(0.9); }
}

/* Glass Panels */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    border-radius: 24px;
}
.glass-btn {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
}
.glass-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}
.theme-light .glass-btn { background: rgba(0, 0, 0, 0.05); }
.theme-light .glass-btn:hover { background: rgba(0, 0, 0, 0.1); }


/* Layout */
.app-wrapper {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
    padding: 1.5rem;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1rem;
    z-index: 10;
}

.aux-clock {
    font-size: 1.5rem;
    font-weight: 600;
    opacity: 0.8;
    letter-spacing: 0.05em;
    font-variant-numeric: tabular-nums;
}
.aux-clock.hidden {
    display: none;
}

.header-actions {
    display: flex;
    gap: 1rem;
}

.icon-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

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

/* Main Display */
.main-display {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.timer-container {
    padding: 4rem 2rem;
    width: 100%;
    max-width: 900px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
    transition: all var(--transition-smooth);
}

.status-message {
    font-size: 2.5rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    opacity: 0.9;
    min-height: 3rem; /* Prevents layout jump if empty */
}

.time-display {
    font-size: clamp(6rem, 20vw, 15rem);
    line-height: 1;
    font-weight: 800;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 4px 12px rgba(0,0,0,0.1);
    white-space: nowrap;
}

/* Dynamic Fonts */
.font-inter { font-family: 'Inter', sans-serif; }
.font-vt323 { font-family: 'VT323', monospace; }
.font-share-tech-mono { font-family: 'Share Tech Mono', monospace; }
.font-roboto-mono { font-family: 'Roboto Mono', monospace; }
.font-montserrat { font-family: 'Montserrat', sans-serif; font-weight: 900; }
.font-oswald { font-family: 'Oswald', sans-serif; }
.font-bebas-neue { font-family: 'Bebas Neue', sans-serif; letter-spacing: 0.05em; }
.font-orbitron { font-family: 'Orbitron', sans-serif; }
.font-courier { font-family: 'Courier Prime', monospace; }
.font-playfair { font-family: 'Playfair Display', serif; }

/* Adjustments for specific fonts */
.font-vt323, .font-share-tech-mono {
    letter-spacing: 0.05em;
}

.controls-row {
    display: flex;
    gap: 1.5rem;
    margin-top: 1rem;
}

.btn {
    padding: 1rem 2rem;
    border-radius: 12px;
    font-size: 1.25rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border: none;
}

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

.btn-primary {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
    border: 1px solid rgba(255,255,255,0.1);
}
.btn-primary:hover {
    background: #2563eb;
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.6);
}

.btn-secondary {
    background: transparent;
    border: 2px solid var(--glass-border);
}
.theme-light .btn-secondary {
    border: 2px solid rgba(0,0,0,0.1);
}

.quick-adds {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
    flex-wrap: wrap;
    justify-content: center;
}

.btn-quick {
    padding: 0.5rem 1rem;
    font-size: 1rem;
    border-radius: 8px;
    font-weight: 600;
}

/* Sidebar Settings */
.sidebar-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 900;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-fast);
}
.sidebar-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.settings-sidebar {
    position: fixed;
    top: 0;
    right: -400px;
    width: 100%;
    max-width: 400px;
    height: 100vh;
    border-radius: 0;
    border-left: 1px solid var(--glass-border);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: right var(--transition-smooth);
    background: var(--glass-bg);
}
.settings-sidebar.active {
    right: 0;
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--glass-border);
}
.settings-header h2 {
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.settings-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.setting-section h3 {
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 0.5rem;
}
.theme-light .setting-section h3 {
    border-bottom: 1px solid rgba(0,0,0,0.1);
}

.form-group {
    margin-bottom: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.row-group {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
}

.form-group label {
    font-weight: 500;
    font-size: 0.95rem;
}

.custom-select, .custom-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    transition: border-color var(--transition-fast);
}
.custom-select:focus, .custom-input:focus {
    border-color: var(--primary-color);
}
.theme-light .custom-select, .theme-light .custom-input {
    background: rgba(255,255,255,0.5);
    color: var(--text-primary);
}
.theme-light .custom-select option {
    background: #fff;
    color: #000;
}
.theme-dark .custom-select option {
    background: #1e293b;
    color: #fff;
}

/* Color Picker */
.color-picker-wrapper {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid var(--glass-border);
    cursor: pointer;
}
.color-picker-wrapper input[type="color"] {
    width: 150%;
    height: 150%;
    margin: -25%;
    cursor: pointer;
    border: none;
    padding: 0;
}

/* Custom Toggle Switch */
.toggle-switch {
    position: relative;
    width: 60px;
    height: 30px;
}
.toggle-input {
    opacity: 0;
    width: 0;
    height: 0;
}
.toggle-label {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(0,0,0,0.3);
    border-radius: 34px;
    transition: .4s;
    border: 1px solid var(--glass-border);
}
.theme-light .toggle-label {
    background-color: rgba(0,0,0,0.1);
}
.toggle-label:before {
    position: absolute;
    content: "";
    height: 22px; width: 22px;
    left: 4px; bottom: 3px;
    background-color: white;
    border-radius: 50%;
    transition: .4s;
}
.toggle-input:checked + .toggle-label {
    background-color: var(--primary-color);
}
.toggle-input:checked + .toggle-label:before {
    transform: translateX(30px);
}

/* Time Input Group */
.time-input-group {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    background: rgba(0,0,0,0.1);
    padding: 1rem;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    margin-bottom: 1rem;
}
.theme-light .time-input-group {
    background: rgba(255,255,255,0.3);
}

.time-field {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}
.time-field input {
    width: 80px;
    text-align: center;
    font-size: 2rem;
    font-weight: 700;
    background: transparent;
    border: none;
    color: var(--text-primary);
    outline: none;
    border-bottom: 2px solid transparent;
    transition: border-color var(--transition-fast);
}
.time-field input:focus {
    border-bottomColor: var(--primary-color);
}
.time-field span {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}
.time-field.divider {
    font-size: 2rem;
    font-weight: 700;
    padding-bottom: 1.25rem;
}

/* Input with suffix */
.input-with-suffix {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.input-with-suffix input {
    width: 80px;
}

.btn-block {
    width: 100%;
}

.app-version {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: auto;
    padding-top: 1rem;
}

/* Responsive Extreme */

/* Tablets / iPads Landscape & Large screens */
@media (max-width: 1024px) {
    .time-display { font-size: clamp(6rem, 18vw, 12rem); }
    .timer-container { padding: 3rem 1.5rem; }
}

/* Portait iPads and large phones */
@media (max-width: 768px) {
    .app-wrapper { padding: 1rem; }
    .time-display { font-size: 22vw; }
    .status-message { font-size: 1.8rem; }
    .controls-row { flex-direction: column; width: 100%; max-width: 300px; }
    .btn { width: 100%; justify-content: center; }
    .timer-container { gap: 1.5rem; }
}

/* Small mobile landscape */
@media (max-height: 500px) and (orientation: landscape) {
    .app-wrapper { padding: 0.5rem; }
    .app-header { padding: 0.5rem; }
    .timer-container { padding: 1rem; gap: 0.5rem; flex-direction: row; flex-wrap: wrap; justify-content: center;}
    .status-message { width: 100%; font-size: 1.5rem; margin-bottom: -0.5rem;}
    .time-display { font-size: 15vh; }
    .controls-row { flex-direction: column; width: auto; margin-top: 0;}
    .quick-adds { width: 100%; margin-top: 0;}
}
