/* CSS Variables */
:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #64748b;
    --background: #0f172a;
    --surface: #1e293b;
    --surface-hover: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border-color: #334155;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -4px rgba(0, 0, 0, 0.2);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.2s ease;
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* App Container */
.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    text-align: center;
    padding: 2rem 1rem;
    background: linear-gradient(135deg, var(--surface) 0%, var(--background) 100%);
    border-bottom: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.logo-img {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
}

.header h1 {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color), #a855f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tagline {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* Main Content */
.main-content {
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
    width: 100%;
}

/* Create Timer Section */
.create-timer-section {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow);
}

.create-timer-section h2 {
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

/* Form Styles */
.timer-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

input[type="text"],
input[type="date"],
input[type="time"] {
    padding: 0.75rem 1rem;
    background: var(--background);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 1rem;
    transition: var(--transition);
}

input[type="text"]:focus,
input[type="date"]:focus,
input[type="time"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

input[type="text"]::placeholder {
    color: var(--text-muted);
}

/* Color Picker */
.color-picker-wrapper {
    display: flex;
    align-items: center;
    gap: 1rem;
}

input[type="color"] {
    width: 48px;
    height: 48px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: none;
    padding: 0;
}

input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

input[type="color"]::-webkit-color-swatch {
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
}

.preset-colors {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.color-preset {
    width: 32px;
    height: 32px;
    border: 2px solid transparent;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
}

.color-preset:hover {
    transform: scale(1.1);
}

.color-preset:nth-child(1) { background: #6366f1; }
.color-preset:nth-child(2) { background: #ec4899; }
.color-preset:nth-child(3) { background: #10b981; }
.color-preset:nth-child(4) { background: #f59e0b; }
.color-preset:nth-child(5) { background: #ef4444; }
.color-preset:nth-child(6) { background: #8b5cf6; }

/* Checkbox */
.checkbox-group {
    flex-direction: row;
    align-items: center;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    font-size: 0.9375rem;
    color: var(--text-primary);
}

.checkbox-label input {
    display: none;
}

.checkbox-custom {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.checkbox-label input:checked + .checkbox-custom {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.checkbox-label input:checked + .checkbox-custom::after {
    content: '✓';
    color: white;
    font-size: 12px;
    font-weight: bold;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

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

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--surface-hover);
    color: var(--text-primary);
}

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

.btn-text {
    background: transparent;
    color: var(--text-secondary);
}

.btn-text:hover {
    color: var(--text-primary);
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-icon {
    font-size: 1.25rem;
    font-weight: 300;
}

.btn-icon-only {
    padding: 0.5rem;
    width: 36px;
    height: 36px;
}

/* Timers Section */
.timers-section {
    margin-bottom: 2rem;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.section-header h2 {
    font-size: 1.25rem;
    color: var(--text-primary);
}

.timer-count {
    font-size: 0.875rem;
    color: var(--text-muted);
    background: var(--surface);
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
}

/* Timers Container */
.timers-container {
    display: grid;
    gap: 1rem;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    background: var(--surface);
    border-radius: var(--radius);
    border: 2px dashed var(--border-color);
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.empty-state h3 {
    font-size: 1.125rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: var(--text-secondary);
    font-size: 0.9375rem;
}

/* Timer Card */
.timer-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--primary-color);
    transition: var(--transition);
}

.timer-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.timer-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.timer-info h3 {
    font-size: 1.125rem;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.timer-date {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.timer-actions {
    display: flex;
    gap: 0.5rem;
}

.timer-actions button {
    background: var(--background);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    font-size: 1rem;
}

.timer-actions button:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.timer-actions button.delete:hover {
    background: var(--error);
    border-color: var(--error);
    color: white;
}

/* Countdown Display */
.countdown-display {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.countdown-unit {
    text-align: center;
    padding: 1rem 0.5rem;
    background: var(--background);
    border-radius: var(--radius-sm);
}

.countdown-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    line-height: 1;
    margin-bottom: 0.25rem;
}

.countdown-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Timer Status */
.timer-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

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

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.timer-status.completed .status-dot {
    background: var(--primary-color);
    animation: none;
}

.timer-status span {
    color: var(--text-secondary);
}

/* Completed Timer State */
.timer-card.completed {
    opacity: 0.8;
}

.timer-card.completed .countdown-display {
    opacity: 0.5;
}

/* Footer */
.footer {
    text-align: center;
    padding: 1.5rem 1rem;
    background: var(--surface);
    border-top: 1px solid var(--border-color);
    margin-top: auto;
}

.footer p {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

.footer a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    max-width: 480px;
    width: 100%;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.2s ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

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

.modal-header h3 {
    font-size: 1.125rem;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

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

.modal-body p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.share-link-container {
    display: flex;
    gap: 0.5rem;
}

.share-link-container input {
    flex: 1;
    padding: 0.75rem 1rem;
    background: var(--background);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.875rem;
}

.share-note {
    font-size: 0.875rem;
    color: var(--success);
    margin-top: 0.5rem;
    min-height: 1.25rem;
}

/* Celebration Modal */
.celebration {
    text-align: center;
}

.celebration-emoji {
    font-size: 4rem;
    margin-bottom: 1rem;
    animation: bounce 0.5s ease infinite alternate;
}

@keyframes bounce {
    from { transform: translateY(0); }
    to { transform: translateY(-10px); }
}

.celebration h3 {
    font-size: 1.5rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.celebration p {
    text-align: center;
}

.celebration .btn {
    margin-top: 1rem;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--surface);
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 1rem;
    z-index: 999;
    opacity: 0;
    transition: all 0.3s ease;
    max-width: 90%;
}

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

.toast p {
    color: var(--text-primary);
    font-size: 0.9375rem;
}

.toast-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header h1 {
        font-size: 1.5rem;
    }

    .tagline {
        font-size: 0.875rem;
    }

    .create-timer-section {
        padding: 1rem;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .color-picker-wrapper {
        flex-direction: column;
        align-items: flex-start;
    }

    .countdown-display {
        grid-template-columns: repeat(4, 1fr);
        gap: 0.5rem;
    }

    .countdown-value {
        font-size: 1.5rem;
    }

    .countdown-label {
        font-size: 0.625rem;
    }

    .timer-card {
        padding: 1rem;
    }

    .timer-card-header {
        flex-direction: column;
        gap: 0.75rem;
    }

    .timer-actions {
        align-self: flex-end;
    }

    .toast {
        flex-direction: column;
        text-align: center;
        padding: 1rem;
    }

    .toast-actions {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .main-content {
        padding: 1rem 0.75rem;
    }

    .countdown-unit {
        padding: 0.75rem 0.25rem;
    }

    .countdown-value {
        font-size: 1.25rem;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}

/* Utilities */
.hidden {
    display: none !important;
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus Styles */
button:focus-visible,
input:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Selection */
::selection {
    background: var(--primary-color);
    color: white;
}
