/* CSS Variables for theming */
:root {
    --primary-color: #5c6bc0;
    --primary-dark: #3f51b5;
    --primary-light: #7986cb;
    --secondary-color: #26a69a;
    --background-color: #f5f7fa;
    --card-background: #ffffff;
    --text-primary: #2c3e50;
    --text-secondary: #607d8b;
    --text-muted: #90a4ae;
    --border-color: #e0e6ed;
    --success-color: #4caf50;
    --warning-color: #ff9800;
    --error-color: #f44336;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
}

/* Reset and Base Styles */
*, *::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, 'Open Sans', 'Helvetica Neue', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
}

/* App Container */
.app-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    text-align: center;
    padding: 30px 0;
    color: white;
}

.logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 10px;
}

.logo {
    width: 48px;
    height: 48px;
    object-fit: contain;
}

header h1 {
    font-size: 1.75rem;
    font-weight: 600;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.tagline {
    font-size: 1rem;
    opacity: 0.9;
    margin-top: 8px;
}

/* Main Content */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Section Styles */
section {
    background: var(--card-background);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-md);
}

section h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-icon {
    width: 24px;
    height: 24px;
    fill: var(--primary-color);
}

/* Status Section */
.status-section {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
}

.status-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    animation: none;
}

.status-indicator.active .status-dot {
    background: var(--success-color);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.2);
    }
}

.status-text {
    font-size: 1.1rem;
    font-weight: 500;
}

.next-bell {
    text-align: right;
}

.next-bell .label {
    display: block;
    font-size: 0.85rem;
    opacity: 0.8;
}

.next-bell .time {
    font-size: 1.75rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* Control Buttons */
.controls-section {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
    background: transparent;
    box-shadow: none;
    padding: 0;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 28px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-normal);
    flex: 1;
    min-width: 120px;
}

.btn-icon {
    width: 20px;
    height: 20px;
}

.btn-primary {
    background: var(--success-color);
    color: white;
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

.btn-primary:hover:not(:disabled) {
    background: #43a047;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(76, 175, 80, 0.4);
}

.btn-secondary {
    background: var(--error-color);
    color: white;
    box-shadow: 0 4px 12px rgba(244, 67, 54, 0.3);
}

.btn-secondary:hover:not(:disabled) {
    background: #e53935;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(244, 67, 54, 0.4);
}

.btn-outline {
    background: var(--card-background);
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.btn-outline:hover:not(:disabled) {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Settings Section */
.setting-group {
    margin-bottom: 24px;
}

.setting-group:last-child {
    margin-bottom: 0;
}

.setting-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.setting-icon {
    width: 20px;
    height: 20px;
    fill: var(--primary-color);
}

.setting-group select,
.setting-group input[type="number"] {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    color: var(--text-primary);
    background: white;
    transition: border-color var(--transition-fast);
    appearance: none;
    cursor: pointer;
}

.setting-group select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='%23607d8b'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 44px;
}

.setting-group select:focus,
.setting-group input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.custom-interval {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
}

.custom-interval input {
    width: 100px;
}

.custom-interval span {
    color: var(--text-secondary);
}

/* Volume Slider */
input[type="range"] {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: var(--border-color);
    appearance: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: transform var(--transition-fast);
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

input[type="range"]::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: none;
    box-shadow: var(--shadow-md);
}

/* Toggle Switch */
.toggle-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
}

.toggle {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 28px;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border-color);
    transition: var(--transition-normal);
    border-radius: 28px;
}

.toggle-slider::before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: var(--transition-normal);
    border-radius: 50%;
    box-shadow: var(--shadow-sm);
}

.toggle input:checked + .toggle-slider {
    background-color: var(--primary-color);
}

.toggle input:checked + .toggle-slider::before {
    transform: translateX(24px);
}

.toggle-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.setting-description {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 8px;
}

/* Schedule Section */
.schedule-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.schedule-options {
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.time-range {
    display: flex;
    align-items: flex-end;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.time-input {
    flex: 1;
    min-width: 120px;
}

.time-input label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.time-input input {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    color: var(--text-primary);
}

.time-input input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.time-separator {
    color: var(--text-muted);
    padding-bottom: 12px;
}

.days-selector label {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.days-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
}

.day-btn {
    padding: 10px 4px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: white;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.day-btn:hover {
    border-color: var(--primary-light);
    color: var(--primary-color);
}

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

/* Stats Section */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.stat-card {
    text-align: center;
    padding: 20px;
    background: linear-gradient(135deg, #f5f7fa 0%, #e8ecf1 100%);
    border-radius: var(--radius-md);
}

.stat-value {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
    font-variant-numeric: tabular-nums;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Footer */
footer {
    text-align: center;
    padding: 30px 0 20px;
    color: rgba(255, 255, 255, 0.8);
}

footer p {
    font-size: 0.9rem;
    margin-bottom: 8px;
}

.powered-by {
    font-size: 0.85rem;
    opacity: 0.9;
}

.powered-by a {
    color: white;
    text-decoration: underline;
    transition: opacity var(--transition-fast);
}

.powered-by a:hover {
    opacity: 0.8;
}

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

/* Bell Animation */
@keyframes bellRing {
    0%, 100% { transform: rotate(0deg); }
    10% { transform: rotate(15deg); }
    20% { transform: rotate(-15deg); }
    30% { transform: rotate(10deg); }
    40% { transform: rotate(-10deg); }
    50% { transform: rotate(5deg); }
    60% { transform: rotate(-5deg); }
    70% { transform: rotate(2deg); }
    80% { transform: rotate(-2deg); }
    90% { transform: rotate(0deg); }
}

.bell-ringing {
    animation: bellRing 1s ease-in-out;
}

/* Visual Feedback Overlay */
.bell-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle, rgba(92, 107, 192, 0.2) 0%, transparent 70%);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.5s ease;
    z-index: 1000;
}

.bell-overlay.active {
    opacity: 1;
}

/* Responsive Design */
@media (max-width: 480px) {
    .app-container {
        padding: 16px;
    }

    header h1 {
        font-size: 1.4rem;
    }

    .tagline {
        font-size: 0.9rem;
    }

    section {
        padding: 20px 16px;
    }

    .status-card {
        flex-direction: column;
        text-align: center;
    }

    .next-bell {
        text-align: center;
    }

    .btn {
        padding: 12px 20px;
        font-size: 0.95rem;
    }

    .days-grid {
        grid-template-columns: repeat(7, 1fr);
        gap: 4px;
    }

    .day-btn {
        padding: 8px 2px;
        font-size: 0.75rem;
    }

    .time-range {
        flex-direction: column;
        gap: 12px;
    }

    .time-input {
        width: 100%;
    }

    .time-separator {
        display: none;
    }

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

@media (max-width: 360px) {
    .controls-section {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }
}

/* Print Styles */
@media print {
    body {
        background: white;
    }

    .controls-section,
    .btn {
        display: none;
    }
}

/* Accessibility - Focus Styles */
*:focus-visible {
    outline: 3px solid var(--primary-light);
    outline-offset: 2px;
}

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