/* ===== CSS Variables ===== */
:root {
    --primary: #00d4aa;
    --primary-dark: #00a88a;
    --primary-glow: rgba(0, 212, 170, 0.4);
    --secondary: #6366f1;
    --background: #0a0e1a;
    --surface: #111827;
    --surface-light: #1f2937;
    --text: #f9fafb;
    --text-muted: #9ca3af;
    --danger: #ef4444;
    --warning: #f59e0b;
    --success: #10b981;
    --border-radius: 16px;
    --transition: all 0.3s ease;
}

/* ===== Reset & Base ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--background);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    background-image: 
        radial-gradient(ellipse at top, rgba(99, 102, 241, 0.1) 0%, transparent 50%),
        radial-gradient(ellipse at bottom, rgba(0, 212, 170, 0.05) 0%, transparent 50%);
}

/* ===== App Container ===== */
.app-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* ===== Language Toggle ===== */
.lang-toggle {
    position: absolute;
    top: 20px;
    left: 20px;
    background: var(--surface);
    border: 1px solid var(--surface-light);
    border-radius: 12px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
}

.lang-toggle:hover {
    background: var(--surface-light);
    border-color: var(--primary);
}

.lang-flag {
    font-size: 18px;
}

/* ===== Settings Button ===== */
.settings-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: var(--surface);
    border: 1px solid var(--surface-light);
    border-radius: 12px;
    padding: 10px;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-muted);
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.settings-btn:hover {
    background: var(--surface-light);
    border-color: var(--primary);
    color: var(--primary);
}

.settings-btn svg {
    width: 22px;
    height: 22px;
}

/* ===== Header ===== */
.header {
    text-align: center;
    padding: 40px 0 20px;
}

.logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.logo h1 {
    font-family: 'Orbitron', monospace;
    font-size: 2rem;
    font-weight: 900;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 2px;
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 400;
}

/* ===== Atom Icon ===== */
.atom-icon {
    width: 60px;
    height: 60px;
    position: relative;
}

.nucleus {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 12px;
    height: 12px;
    background: var(--primary);
    border-radius: 50%;
    box-shadow: 0 0 20px var(--primary-glow);
}

.electron-orbit {
    position: absolute;
    top: 50%;
    left: 50%;
    border: 1px solid rgba(0, 212, 170, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
}

.orbit-1 {
    width: 30px;
    height: 30px;
    animation: rotate 3s linear infinite;
}

.orbit-2 {
    width: 45px;
    height: 45px;
    transform: translate(-50%, -50%) rotate(60deg);
    animation: rotate 4s linear infinite reverse;
}

.orbit-3 {
    width: 58px;
    height: 58px;
    transform: translate(-50%, -50%) rotate(-30deg);
    animation: rotate 5s linear infinite;
}

.electron {
    position: absolute;
    width: 6px;
    height: 6px;
    background: var(--secondary);
    border-radius: 50%;
    top: -3px;
    left: 50%;
    transform: translateX(-50%);
    box-shadow: 0 0 10px var(--secondary);
}

@keyframes rotate {
    from { transform: translate(-50%, -50%) rotate(0deg); }
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* ===== Main Display ===== */
.main-display {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

/* ===== Counter Container ===== */
.counter-container {
    position: relative;
    width: 240px;
    height: 240px;
}

.counter-ring {
    position: relative;
    width: 100%;
    height: 100%;
}

.progress-ring {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.progress-ring-bg {
    fill: none;
    stroke: var(--surface-light);
    stroke-width: 8;
}

.progress-ring-fill {
    fill: none;
    stroke: url(#gradient);
    stroke: var(--primary);
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 565.48;
    stroke-dashoffset: 565.48;
    transition: stroke-dashoffset 0.3s ease;
    filter: drop-shadow(0 0 8px var(--primary-glow));
}

.counter-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.decay-count {
    font-family: 'Orbitron', monospace;
    font-size: 3.5rem;
    font-weight: 900;
    color: var(--primary);
    line-height: 1;
    text-shadow: 0 0 30px var(--primary-glow);
}

.decay-count.pulse {
    animation: pulse 0.15s ease-out;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.decay-target {
    font-family: 'Orbitron', monospace;
    font-size: 1.2rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.decay-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-top: 8px;
}

/* ===== Particles ===== */
.particles-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: visible;
}

.particle {
    position: absolute;
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
    top: 50%;
    left: 50%;
    animation: particle-burst 0.8s ease-out forwards;
    box-shadow: 0 0 10px var(--primary);
}

@keyframes particle-burst {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(calc(-50% + var(--tx)), calc(-50% + var(--ty))) scale(0);
    }
}

/* ===== Time Display ===== */
.time-display {
    text-align: center;
}

.time-value {
    font-family: 'Orbitron', monospace;
    font-size: 2rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: 2px;
}

.time-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 4px;
}

/* ===== Stats Row ===== */
.stats-row {
    display: flex;
    gap: 16px;
    width: 100%;
}

.stat-card {
    flex: 1;
    background: var(--surface);
    border: 1px solid var(--surface-light);
    border-radius: var(--border-radius);
    padding: 16px;
    text-align: center;
    transition: var(--transition);
}

.stat-card:hover {
    border-color: var(--primary);
    box-shadow: 0 0 20px rgba(0, 212, 170, 0.1);
}

.stat-value {
    font-family: 'Orbitron', monospace;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

/* ===== Target Selector ===== */
.target-selector {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--surface);
    border: 1px solid var(--surface-light);
    border-radius: var(--border-radius);
    padding: 16px 24px;
}

.target-label {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 500;
}

.target-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.target-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid var(--surface-light);
    background: var(--surface-light);
    color: var(--text);
    font-size: 1.4rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.target-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--background);
}

.target-input {
    width: 80px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid var(--surface-light);
    background: var(--background);
    color: var(--text);
    font-family: 'Orbitron', monospace;
    font-size: 1.1rem;
    text-align: center;
    font-weight: 600;
}

.target-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

/* ===== Control Buttons ===== */
.controls {
    display: flex;
    gap: 12px;
    width: 100%;
}

.control-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px 24px;
    border-radius: var(--border-radius);
    border: none;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.control-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-icon {
    width: 20px;
    height: 20px;
}

.start-btn {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--background);
    box-shadow: 0 4px 20px var(--primary-glow);
}

.start-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 30px var(--primary-glow);
}

.stop-btn {
    background: var(--danger);
    color: white;
}

.stop-btn:hover:not(:disabled) {
    background: #dc2626;
    transform: translateY(-2px);
}

.reset-btn {
    background: var(--surface-light);
    color: var(--text);
    border: 1px solid var(--surface-light);
}

.reset-btn:hover:not(:disabled) {
    background: var(--surface);
    border-color: var(--text-muted);
}

/* ===== Footer ===== */
.footer {
    text-align: center;
    padding: 20px 0;
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* ===== Modal ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--surface);
    border: 1px solid var(--surface-light);
    border-radius: var(--border-radius);
    width: 90%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.9) translateY(20px);
    transition: var(--transition);
}

.modal-overlay.active .modal {
    transform: scale(1) translateY(0);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--surface-light);
}

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 4px 8px;
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--text);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--surface-light);
    display: flex;
    justify-content: flex-end;
}

/* ===== Settings ===== */
.setting-group {
    margin-bottom: 24px;
}

.setting-group:last-child {
    margin-bottom: 0;
}

.setting-label {
    font-weight: 600;
    margin-bottom: 8px;
    display: block;
}

.setting-description {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.activity-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.preset-btn {
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid var(--surface-light);
    background: var(--background);
    color: var(--text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition);
}

.preset-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.preset-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--background);
    font-weight: 600;
}

.custom-activity {
    display: flex;
    align-items: center;
    gap: 12px;
}

.custom-activity label {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.activity-input {
    width: 100px;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--surface-light);
    background: var(--background);
    color: var(--text);
    font-family: 'Orbitron', monospace;
    font-size: 1rem;
    text-align: center;
}

.activity-input:focus {
    outline: none;
    border-color: var(--primary);
}

/* ===== Toggle Switch ===== */
.toggle-switch {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.toggle-switch input {
    display: none;
}

.toggle-slider {
    width: 50px;
    height: 28px;
    background: var(--surface-light);
    border-radius: 14px;
    position: relative;
    transition: var(--transition);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    top: 4px;
    left: 4px;
    width: 20px;
    height: 20px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: var(--transition);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--primary);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(22px);
    background: white;
}

.toggle-text {
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* ===== Modal Button ===== */
.modal-btn {
    padding: 12px 24px;
    border-radius: 10px;
    border: none;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.save-btn {
    background: var(--primary);
    color: var(--background);
}

.save-btn:hover {
    background: var(--primary-dark);
}

/* ===== Completion Modal ===== */
.completion-modal {
    text-align: center;
    padding: 40px 24px;
}

.completion-icon {
    font-size: 4rem;
    margin-bottom: 16px;
}

.completion-modal h2 {
    font-size: 1.5rem;
    margin-bottom: 24px;
    color: var(--primary);
}

.completion-stats {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin-bottom: 32px;
    flex-wrap: wrap;
}

.completion-stat {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.completion-value {
    font-family: 'Orbitron', monospace;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
}

.completion-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.completion-modal .modal-btn {
    min-width: 150px;
}

/* ===== Running State ===== */
.app-container.running .counter-ring {
    animation: glow-pulse 2s ease-in-out infinite;
}

@keyframes glow-pulse {
    0%, 100% { filter: drop-shadow(0 0 10px var(--primary-glow)); }
    50% { filter: drop-shadow(0 0 25px var(--primary-glow)); }
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
    .app-container {
        padding: 16px;
    }
    
    .logo h1 {
        font-size: 1.6rem;
    }
    
    .counter-container {
        width: 200px;
        height: 200px;
    }
    
    .decay-count {
        font-size: 2.8rem;
    }
    
    .stats-row {
        flex-direction: column;
    }
    
    .controls {
        flex-direction: column;
    }
    
    .target-selector {
        flex-direction: column;
        gap: 12px;
    }
    
    .completion-stats {
        flex-direction: column;
        gap: 16px;
    }
}
