@import url('https://fonts.googleapis.com/css2?family=Prompt:wght@300;400;500;600;700&display=swap');

:root {
    --bg-primary: #0F172A;
    --bg-card: #1E293B;
    --bg-card-hover: #334155;
    --text-primary: #F8FAFC;
    --text-secondary: #94A3B8;
    --text-muted: #64748B;
    --accent-gold: #F59E0B;
    --accent-gold-glow: rgba(245, 158, 11, 0.25);
    --accent-teal: #10B981;
    --accent-teal-glow: rgba(16, 185, 129, 0.25);
    --accent-indigo: #6366F1;
    --danger: #EF4444;
    --border-color: rgba(255, 255, 255, 0.08);
    --font-family: 'Prompt', -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: var(--font-family);
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    background-image: 
        radial-gradient(circle at 50% 0%, rgba(245, 158, 11, 0.12) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(99, 102, 241, 0.08) 0%, transparent 40%);
}

/* App Container */
.app-container {
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    padding-bottom: 80px; /* Space for bottom nav */
}

/* Header */
.app-header {
    padding: 20px 20px 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.brand-title {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    line-height: 1.2;
}

.brand-title .icon {
    font-size: 1.6rem;
    line-height: 1;
    margin-bottom: 2px;
}

.brand-name {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    line-height: 1.1;
    margin-bottom: 3px;
}

.app-version-sub {
    font-size: 0.62rem;
    font-weight: 600;
    color: var(--accent-gold);
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid var(--accent-gold-glow);
    padding: 2px 7px;
    border-radius: 8px;
    line-height: 1;
    display: inline-block;
    letter-spacing: 0.5px;
}

.user-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.06);
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.btn-logout-prominent {
    background: rgba(239, 68, 68, 0.15);
    color: #FCA5A5;
    border: 1px solid rgba(239, 68, 68, 0.4);
    padding: 6px 12px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s ease;
}

.btn-logout-prominent:hover {
    background: rgba(239, 68, 68, 0.3);
    color: #ffffff;
    border-color: #EF4444;
}

/* Main Content Views */
.view {
    display: none;
    padding: 16px 20px;
    animation: fadeIn 0.3s ease-out;
}

.view.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Timer View Specifics */
.timer-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 10px;
}

.timer-mode-selector {
    display: flex;
    background: rgba(255, 255, 255, 0.05);
    padding: 4px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    margin-bottom: 20px;
    width: 100%;
    max-width: 320px;
}

.timer-mode-btn {
    flex: 1;
    padding: 10px;
    border: none;
    background: none;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.timer-mode-btn.active {
    background: var(--accent-gold);
    color: #0F172A;
    font-weight: 600;
    box-shadow: 0 4px 12px var(--accent-gold-glow);
}

/* Countdown Presets */
.countdown-config {
    width: 100%;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
}

.preset-pills {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.preset-pill {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.preset-pill.active {
    border-color: var(--accent-gold);
    color: var(--accent-gold);
    background: rgba(245, 158, 11, 0.1);
}

.time-inputs {
    display: flex;
    align-items: center;
    gap: 10px;
}

.time-input-group {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.time-input-group input {
    width: 65px;
    height: 48px;
    text-align: center;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 1.25rem;
    font-weight: 600;
}

.time-input-group label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* BIG TIMER DISPLAY */
.timer-circle-wrap {
    position: relative;
    width: 270px;
    height: 270px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 10px 0 30px;
}

.timer-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.timer-bg-circle {
    fill: none;
    stroke: rgba(255, 255, 255, 0.05);
    stroke-width: 8;
}

.timer-progress-circle {
    fill: none;
    stroke: var(--accent-gold);
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 816;
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 0.3s linear;
}

.timer-display {
    text-align: center;
    z-index: 2;
}

.huge-time {
    font-size: 3.5rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    text-shadow: 0 0 20px var(--accent-gold-glow);
}

.timer-status-label {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 4px;
    font-weight: 400;
}

/* Alert Settings Box */
.alert-settings-box {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 24px;
}

.settings-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.form-group-compact {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group-compact label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.select-compact {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 0.85rem;
    outline: none;
}

.select-compact option {
    background: var(--bg-card);
    color: var(--text-primary);
}

/* Timer Control Buttons */
.timer-controls {
    display: flex;
    gap: 12px;
    width: 100%;
    justify-content: center;
}

.btn {
    padding: 14px 24px;
    border-radius: 14px;
    border: none;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
}

.btn-lg {
    padding: 16px 32px;
    font-size: 1.1rem;
    flex: 1;
}

.btn-primary {
    background: linear-gradient(135deg, #F59E0B 0%, #D97706 100%);
    color: #0F172A;
    box-shadow: 0 6px 20px var(--accent-gold-glow);
}

.btn-primary:active {
    transform: scale(0.97);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-danger {
    background: linear-gradient(135deg, #EF4444 0%, #DC2626 100%);
    color: white;
}

.btn-success {
    background: linear-gradient(135deg, #10B981 0%, #059669 100%);
    color: white;
    box-shadow: 0 6px 20px var(--accent-teal-glow);
}

.btn-line {
    background: #00B900;
    color: white;
    box-shadow: 0 4px 14px rgba(0, 185, 0, 0.3);
}

/* Bottom Navigation Bar */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    background: rgba(15, 23, 42, 0.92);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-around;
    padding: 8px 0;
    z-index: 100;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.75rem;
    padding: 6px 16px;
    border-radius: 12px;
    cursor: pointer;
    transition: color 0.2s;
}

.nav-item .nav-icon {
    font-size: 1.25rem;
}

.nav-item.active {
    color: var(--accent-gold);
    font-weight: 500;
}

/* Modal Styling */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: flex-end;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.modal-overlay.active,
.modal-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-top-left-radius: 24px;
    border-top-right-radius: 24px;
    width: 100%;
    max-width: 480px;
    padding: 24px;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(100%);
    transition: transform 0.3s ease-out;
}

.modal-overlay.active .modal-card,
.modal-overlay.show .modal-card {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-title {
    font-size: 1.2rem;
    font-weight: 600;
}

/* History Cards */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.history-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.history-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-date {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--accent-gold);
}

.history-time {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.history-duration {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
}

.history-note {
    background: rgba(0, 0, 0, 0.2);
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.4;
    border-left: 3px solid var(--accent-gold);
}

.history-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 4px;
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.stat-card.full-width {
    grid-column: span 2;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-gold);
}

.stat-subtext {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Bar Chart Styles */
.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 20px;
}

.chart-title {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-secondary);
}

.bar-chart-container {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    height: 150px;
    padding-top: 24px;
    gap: 4px;
}

.bar-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    flex: 1;
    position: relative;
}

.bar-value-label {
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--accent-gold);
    text-align: center;
    position: absolute;
    top: -20px;
    white-space: nowrap;
    opacity: 0.9;
}

.bar-wrapper {
    height: 110px;
    width: 100%;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    position: relative;
}

.bar-fill {
    width: 22px;
    background: linear-gradient(to top, #D97706, #F59E0B, #FBBF24);
    border-radius: 6px 6px 2px 2px;
    transition: height 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: 4px;
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.2);
}

.bar-fill:hover {
    background: linear-gradient(to top, #F59E0B, #FBBF24, #34D399);
    box-shadow: 0 0 15px rgba(245, 158, 11, 0.5);
    cursor: pointer;
}

.bar-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
}

/* Form controls */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.form-group label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.input-control {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 12px 14px;
    border-radius: 12px;
    font-size: 0.95rem;
    outline: none;
}

.input-control:focus {
    border-color: var(--accent-gold);
}

textarea.input-control {
    resize: none;
    min-height: 90px;
}

/* Auth Container */
.auth-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 80vh;
    padding: 20px;
}

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 28px 24px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.auth-header {
    text-align: center;
    margin-bottom: 24px;
}

.auth-header h2 {
    font-size: 1.5rem;
    margin-bottom: 6px;
}

.auth-header p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.alert-msg {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid var(--danger);
    color: #FCA5A5;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    margin-bottom: 16px;
    display: none;
}

/* Screen Flash Alert Overlay */
.screen-flash-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: white;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
}

.screen-flash-overlay.flashing {
    animation: flashPulse 0.5s infinite alternate;
}

@keyframes flashPulse {
    from { opacity: 0; }
    to { opacity: 0.85; }
}

/* Mobile Responsive Header Enhancements (Logged In Header) */
@media (max-width: 600px) {
    .app-header {
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 12px;
        padding: 16px 16px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
        background: rgba(15, 23, 42, 0.4);
    }

    .brand-title {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-align: center;
    }

    .brand-title .icon {
        font-size: 1.8rem;
        line-height: 1;
        margin-bottom: 3px;
    }

    .brand-name {
        font-size: 1.15rem;
        font-weight: 700;
        color: var(--text-primary);
        line-height: 1.1;
        margin-bottom: 4px;
    }

    .app-version-sub {
        font-size: 0.65rem;
        font-weight: 600;
        color: var(--accent-gold);
        background: rgba(245, 158, 11, 0.15);
        border: 1px solid var(--accent-gold-glow);
        padding: 2px 8px;
        border-radius: 10px;
        line-height: 1;
        letter-spacing: 0.5px;
    }

    .user-header-actions {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        justify-content: center;
        gap: 8px;
        width: 100%;
    }

    .user-badge {
        padding: 5px 10px;
        font-size: 0.8rem;
        border-radius: 12px;
    }

    .btn-open-pwd-action, .btn-logout-prominent {
        padding: 5px 10px;
        font-size: 0.78rem;
        border-radius: 10px;
    }
}
