/* ===== DESIGN TOKENS ===== */
:root {
    /* Colors */
    --bg: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --card-bg: hsla(0, 0%, 100%, 0.15);
    --accent: #5a6cff;
    --accent-hover: #4c5dff;
    --txt-primary: #ffffff;
    --txt-secondary: hsla(0, 0%, 100%, 0.8);
    --txt-muted: hsla(0, 0%, 100%, 0.6);

    /* Surfaces */
    --surface-1: hsla(0, 0%, 100%, 0.1);
    --surface-2: hsla(0, 0%, 100%, 0.15);
    --surface-3: hsla(0, 0%, 100%, 0.2);

    /* Effects */
    --shadow-sm: 0 4px 15px rgba(31, 38, 135, 0.2);
    --shadow-md: 0 8px 32px rgba(31, 38, 135, 0.37);
    --shadow-lg: 0 12px 40px rgba(31, 38, 135, 0.5);
    --border: 1px solid hsla(0, 0%, 100%, 0.18);
    --border-hover: 1px solid hsla(0, 0%, 100%, 0.3);
    --blur: blur(25px);

    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 2.5rem;

    /* Border radius */
    --radius-sm: 0.5rem;
    --radius-md: 1rem;
    --radius-lg: 1.5rem;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-base: 0.3s ease;
    --transition-slow: 0.4s ease;

    /* Typography */
    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 2rem;
}

.dark {
    --bg: linear-gradient(135deg, #0c0c0c 0%, #1a1a2e 50%, #16213e 100%);
    --card-bg: hsla(220, 20%, 16%, 0.25);
    --accent: #91a0ff;
    --accent-hover: #7c8cff;
    --txt-primary: #f1f2f3;
    --txt-secondary: hsla(0, 0%, 100%, 0.7);
    --txt-muted: hsla(0, 0%, 100%, 0.5);
    --surface-1: hsla(220, 20%, 16%, 0.15);
    --surface-2: hsla(220, 20%, 16%, 0.25);
    --surface-3: hsla(220, 20%, 16%, 0.35);
    --shadow-sm: 0 4px 15px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.6);
}

/* ===== GLOBAL STYLES ===== */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    height: 100%;
    scroll-behavior: smooth;
}

body {
    height: 100%;
    margin: 0;
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    line-height: 1.6;
    background: var(--bg);
    background-image: var(--bg-image);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    color: var(--txt-primary);
    transition: all var(--transition-slow);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--space-lg);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===== FOCUS STYLES (Accessibility) ===== */
*:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* ===== MAIN LAYOUT ===== */
main.card {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-xl);
    width: 100%;
    max-width: 1200px;
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: var(--border);
    padding: var(--space-2xl);
    animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@media (min-width: 768px) {
    main.card {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-2xl);
    }

    .header,
    .weather,
    .search,
    .quote,
    .pomodoro {
        grid-column: span 2;
    }
}

@media (min-width: 1024px) {
    body {
        padding: var(--space-2xl);
    }

    main.card {
        padding: 3rem;
    }
}

/* ===== ANIMATIONS ===== */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* ===== COMPONENT STYLES ===== */

/* Section Headers */
section > h3 {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: var(--font-size-xl);
    font-weight: 600;
    margin: 0 0 var(--space-md);
    color: var(--txt-primary);
}

/* Header Section */
.header {
    text-align: center;
    padding: var(--space-lg) 0;
}

#clock {
    font-size: clamp(2.8rem, 6vw, 4.5rem);
    font-weight: 700;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: var(--space-sm);
}

#date {
    font-size: var(--font-size-lg);
    font-weight: 500;
    color: var(--txt-secondary);
}

/* Weather Widget */
.weather {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-lg) var(--space-xl);
    background: var(--surface-2);
    border-radius: var(--radius-md);
    border: var(--border);
    transition: all var(--transition-base);
}

.weather:hover {
    background: var(--surface-3);
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.weather-temp {
    font-size: var(--font-size-2xl);
    font-weight: 600;
}

.weather-desc,
.weather-location {
    font-size: var(--font-size-sm);
    color: var(--txt-secondary);
}

/* Search */
.search {
    width: 100%;
    display: flex;
    gap: var(--space-md);
    flex-wrap: wrap;
}

.search select,
.search input,
.search button {
    border-radius: var(--radius-md);
    border: var(--border);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: all var(--transition-base);
    font-size: var(--font-size-base);
    font-family: inherit;
}

.search select {
    padding: var(--space-md) var(--space-sm);
    background: var(--surface-2);
    color: var(--txt-primary);
    cursor: pointer;
}

.search select:hover,
.search select:focus {
    background: var(--surface-3);
    border-color: var(--border-hover);
}

.search input {
    flex: 1;
    min-width: 200px;
    padding: var(--space-md) var(--space-lg);
    background: var(--surface-2);
    color: var(--txt-primary);
}

.search input::placeholder {
    color: var(--txt-muted);
}

.search input:hover,
.search input:focus {
    background: var(--surface-3);
    border-color: var(--border-hover);
}

.search button {
    padding: var(--space-md) var(--space-xl);
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    border: none;
    cursor: pointer;
}

.search button:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.search button:active {
    transform: translateY(0);
}

/* Search Suggestions */
.suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--card-bg);
    backdrop-filter: var(--blur);
    border: var(--border);
    border-radius: var(--radius-sm);
    margin-top: var(--space-sm);
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    display: none;
    animation: fadeIn var(--transition-fast);
}

.suggestion-item {
    padding: var(--space-md) var(--space-lg);
    cursor: pointer;
    transition: background-color var(--transition-fast);
}

.suggestion-item:hover {
    background: var(--surface-1);
}

/* Quick Links */
.links-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-md);
}

.links {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: var(--space-md);
}

.link-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-lg);
    border-radius: var(--radius-md);
    background: var(--surface-2);
    color: var(--txt-primary);
    text-decoration: none;
    transition: all var(--transition-base);
    box-shadow: var(--shadow-sm);
}

.link-item:hover {
    transform: translateY(-3px) scale(1.03);
    box-shadow: var(--shadow-lg);
    background: var(--surface-3);
}

.link-item img {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
}

.link-item .delete-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #ff4757;
    color: #fff;
    border: none;
    display: none;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.link-item:hover .delete-btn {
    display: flex;
    align-items: center;
    justify-content: center;
}

.delete-btn:hover {
    background: #ff3742;
    transform: scale(1.1);
}

/* Notes */
.notes textarea {
    width: 100%;
    min-height: 80px;
    padding: var(--space-md);
    border-radius: var(--radius-md);
    background: var(--surface-2);
    color: var(--txt-primary);
    border: var(--border);
    resize: vertical;
    font-family: inherit;
    transition: all var(--transition-base);
}

.notes textarea:hover,
.notes textarea:focus {
    background: var(--surface-3);
    border-color: var(--border-hover);
}

.notes textarea::placeholder {
    color: var(--txt-muted);
}

/* Todo */
.todo-input {
    display: flex;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
}

.todo-input input {
    flex: 1;
    padding: var(--space-md);
    border-radius: var(--radius-sm);
    border: var(--border);
    background: var(--surface-2);
    color: var(--txt-primary);
    transition: all var(--transition-base);
}

.todo-input input:hover,
.todo-input input:focus {
    background: var(--surface-3);
    border-color: var(--border-hover);
}

.todo-input button {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    padding: 0 var(--space-md);
    cursor: pointer;
    transition: all var(--transition-base);
}

.todo-input button:hover {
    background: var(--accent-hover);
}

#todoList {
    list-style: none;
    padding: 0;
    margin: 0;
}

#todoList li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm) var(--space-md);
    margin-bottom: var(--space-xs);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    transition: all var(--transition-base);
}

#todoList li:hover {
    background: var(--surface-3);
}

#todoList li.completed {
    text-decoration: line-through;
    opacity: 0.5;
}

/* Quote */
.quote {
    padding: var(--space-lg);
    border-radius: var(--radius-md);
    text-align: center;
    background: var(--surface-1);
    border: var(--border);
}

/* Pomodoro Timer */
.pomodoro {
    text-align: center;
    padding: var(--space-lg);
}

.timer-wrapper {
    position: relative;
    display: inline-block;
    margin-bottom: var(--space-lg);
}

.progress-ring__bg {
    fill: none;
    stroke: var(--surface-2);
    stroke-width: 10;
}

.progress-ring__circle {
    fill: none;
    stroke: var(--accent);
    stroke-width: 10;
    stroke-linecap: round;
    transition: stroke-dashoffset 1s linear;
}

.timer-display {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: var(--font-size-3xl);
    font-weight: 700;
}

.session-label {
    font-size: var(--font-size-sm);
    color: var(--txt-secondary);
    margin: var(--space-sm) 0;
}

.timer-controls {
    display: flex;
    justify-content: center;
    gap: var(--space-sm);
    margin: var(--space-md) 0;
}

.timer-controls button {
    padding: var(--space-sm) var(--space-lg);
    border: none;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
}

.timer-controls button:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.work-mode .progress-ring__circle {
    stroke: #f44336;
}

.break-mode .progress-ring__circle {
    stroke: #4caf50;
}

/* ===== FOOTER ===== */
footer {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-lg);
    width: 100%;
    max-width: 1200px;
    margin-top: var(--space-xl);
}

.footer-item {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-md);
}

/* Theme Toggle */
.toggle {
    width: 50px;
    height: 26px;
    border-radius: 13px;
    background: var(--surface-3);
    position: relative;
    cursor: pointer;
    border: var(--border);
    transition: all var(--transition-base);
}

.toggle::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 22px;
    height: 22px;
    background: #fff;
    border-radius: 50%;
    transition: all var(--transition-base);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle:hover {
    background: var(--accent);
}

.dark .toggle {
    background: var(--accent);
}

.dark .toggle::after {
    transform: translateX(24px);
}

/* ===== UTILITY CLASSES ===== */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ===== PRINT STYLES ===== */
@media print {
    .search,
    .timer-controls,
    .toggle,
    footer {
        display: none;
    }

    main.card {
        box-shadow: none;
        border: 1px solid #000;
    }
}

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

/* ===== MODAL STYLES ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: none; /* Hidden by default */
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity var(--transition-base);
}

.modal[aria-hidden="false"] {
    display: flex;
    opacity: 1;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.modal-content {
    background: var(--card-bg);
    backdrop-filter: var(--blur);
    border-radius: var(--radius-lg);
    border: var(--border);
    box-shadow: var(--shadow-lg);
    padding: var(--space-2xl);
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    transform: scale(0.9);
    transition: transform var(--transition-base);
}

.modal[aria-hidden="false"] .modal-content {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-lg);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--txt-secondary);
    cursor: pointer;
    padding: var(--space-sm);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--surface-1);
    color: var(--txt-primary);
}

.modal-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.form-group label {
    font-weight: 600;
    color: var(--txt-primary);
}

.form-group input {
    padding: var(--space-md);
    border-radius: var(--radius-md);
    border: var(--border);
    background: var(--surface-2);
    color: var(--txt-primary);
    transition: all var(--transition-base);
}

.form-group input:focus {
    border-color: var(--accent);
    background: var(--surface-3);
}

.form-help {
    font-size: var(--font-size-sm);
    color: var(--txt-secondary);
}

.modal-actions {
    display: flex;
    gap: var(--space-md);
    justify-content: flex-end;
    margin-top: var(--space-lg);
}

.btn-secondary {
    padding: var(--space-md) var(--space-lg);
    border: var(--border);
    border-radius: var(--radius-md);
    background: var(--surface-2);
    color: var(--txt-primary);
    cursor: pointer;
    transition: all var(--transition-base);
}

.btn-primary {
    padding: var(--space-md) var(--space-lg);
    border: none;
    border-radius: var(--radius-md);
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
}

.btn-secondary:hover {
    background: var(--surface-3);
}

.btn-primary:hover {
    background: var(--accent-hover);
}
