/* CSS Custom Properties */
:root {
    --primary-color: #7868E6;
    --secondary-color: #B8B5FF;
    --accent-color: #E4FBFF;
    --background-color: #EDEEF7;
    --danger-color: #FFB4B4;
    --text-dark: #2C2C2C;
    --text-light: #666666;
    --white: #FFFFFF;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --border-radius: 8px;
    --transition: all 0.3s ease;
    --font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

body {
    font-family: var(--font-family);
    line-height: 1.6;
    color: var(--text-dark);
    background-color: var(--background-color);
    background-image: url('paper-texture.jpg');
    background-size: cover;
    background-attachment: fixed;
    background-repeat: no-repeat;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header Styles */
.header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: var(--white);
    padding: 2rem 1rem;
    text-align: center;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('paper-texture.jpg');
    opacity: 0.1;
    z-index: 1;
}

.header__title {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    position: relative;
    z-index: 2;
}

.header__subtitle {
    font-size: 1.2rem;
    opacity: 0.9;
    position: relative;
    z-index: 2;
}

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

/* Section Styles */
section {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('paper-texture.jpg');
    opacity: 0.05;
    z-index: 1;
}

section > * {
    position: relative;
    z-index: 2;
}

section h2 {
    color: var(--primary-color);
    font-size: 1.8rem;
    margin-bottom: 1.5rem;
    text-align: center;
}

/* Timer Styles */
.timer-container {
    text-align: center;
}

.timer-display {
    background: linear-gradient(135deg, var(--accent-color), var(--white));
    border-radius: 50%;
    width: 250px;
    height: 250px;
    margin: 0 auto 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
    border: 5px solid var(--secondary-color);
}

.timer-display__time {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-color);
    font-family: 'Courier New', monospace;
}

.timer-controls {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.session-info {
    background: var(--accent-color);
    padding: 1rem;
    border-radius: var(--border-radius);
    margin-top: 1rem;
}

.session-info h3 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

/* Button Styles */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    display: inline-block;
    text-align: center;
    min-width: 120px;
}

.btn:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

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

.btn--primary:hover:not(:disabled) {
    background: #6B5AE0;
    transform: translateY(-2px);
}

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

.btn--secondary:hover:not(:disabled) {
    background: #A8A4FF;
    transform: translateY(-2px);
}

.btn--danger {
    background: var(--danger-color);
    color: var(--text-dark);
}

.btn--danger:hover:not(:disabled) {
    background: #FF9999;
    transform: translateY(-2px);
}

.btn--full {
    width: 100%;
}

/* Form Styles */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-dark);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--secondary-color);
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: var(--transition);
    background: var(--white);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(120, 104, 230, 0.1);
}

.form-help {
    color: var(--text-light);
    font-size: 0.875rem;
    margin-top: 0.25rem;
    display: block;
}

.form-textarea {
    resize: vertical;
    min-height: 80px;
}

/* Checkbox Styles */
.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-weight: 600;
}

.checkbox-input {
    display: none;
}

.checkbox-custom {
    width: 20px;
    height: 20px;
    border: 2px solid var(--secondary-color);
    border-radius: 4px;
    margin-right: 0.5rem;
    position: relative;
    transition: var(--transition);
}

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

.checkbox-input:checked + .checkbox-custom::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--white);
    font-size: 0.875rem;
    font-weight: bold;
}

/* Statistics Styles */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: linear-gradient(135deg, var(--accent-color), var(--white));
    padding: 1.5rem;
    border-radius: var(--border-radius);
    text-align: center;
    box-shadow: var(--shadow);
    border: 2px solid var(--secondary-color);
}

.stat-card h3 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.25rem;
}

.stat-sessions {
    color: var(--text-light);
    font-size: 0.9rem;
}

/* Chart Styles */
.chart-container {
    background: var(--white);
    padding: 1rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow-x: auto;
}

#productionChart {
    max-width: 100%;
    height: auto;
}

/* Goals Styles */
.goals-progress {
    margin-top: 2rem;
}

.progress-item {
    margin-bottom: 1.5rem;
}

.progress-item h4 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.progress-bar {
    width: 100%;
    height: 20px;
    background: var(--accent-color);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    transition: width 0.5s ease;
    border-radius: 10px;
}

.progress-text {
    color: var(--text-light);
    font-size: 0.9rem;
}

/* History Styles */
.history-filters {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    align-items: center;
}

.history-list {
    max-height: 400px;
    overflow-y: auto;
}

.history-item {
    background: var(--accent-color);
    padding: 1rem;
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
    border-left: 4px solid var(--primary-color);
}

.history-item__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.history-item__date {
    font-weight: 600;
    color: var(--primary-color);
}

.history-item__volume {
    font-weight: 700;
    color: var(--text-dark);
}

.history-item__duration {
    color: var(--text-light);
    font-size: 0.9rem;
}

.history-item__notes {
    color: var(--text-light);
    font-style: italic;
    margin-top: 0.5rem;
}

.history-item__actions {
    margin-top: 0.5rem;
    display: flex;
    gap: 0.5rem;
}

.btn--small {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
    min-width: auto;
}

/* Footer Styles */
.footer {
    background: var(--primary-color);
    color: var(--white);
    text-align: center;
    padding: 1.5rem;
    margin-top: auto;
}

.footer__text {
    margin: 0;
}

.footer__text a {
    color: var(--accent-color);
    text-decoration: none;
    transition: var(--transition);
}

.footer__text a:hover {
    text-decoration: underline;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    color: var(--white);
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid var(--white);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    max-width: 400px;
}

.toast {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 1rem;
    margin-bottom: 0.5rem;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--primary-color);
    animation: slideIn 0.3s ease;
    position: relative;
}

.toast--success {
    border-left-color: #4CAF50;
}

.toast--error {
    border-left-color: var(--danger-color);
}

.toast--warning {
    border-left-color: #FF9800;
}

.toast__close {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--text-light);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .header__title {
        font-size: 2rem;
    }
    
    .header__subtitle {
        font-size: 1rem;
    }
    
    .main {
        padding: 1rem;
    }
    
    section {
        padding: 1.5rem;
    }
    
    .timer-display {
        width: 200px;
        height: 200px;
    }
    
    .timer-display__time {
        font-size: 2rem;
    }
    
    .timer-controls {
        flex-direction: column;
        align-items: center;
    }
    
    .btn {
        width: 100%;
        max-width: 200px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .history-filters {
        flex-direction: column;
        align-items: stretch;
    }
    
    .history-item__header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .toast-container {
        left: 20px;
        right: 20px;
        max-width: none;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 1.5rem 1rem;
    }
    
    .header__title {
        font-size: 1.8rem;
    }
    
    .timer-display {
        width: 180px;
        height: 180px;
    }
    
    .timer-display__time {
        font-size: 1.8rem;
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
    
    section {
        padding: 1rem;
    }
}

/* Print Styles */
@media print {
    .header,
    .footer,
    .timer-controls,
    .btn,
    .loading-overlay,
    .toast-container {
        display: none;
    }
    
    body {
        background: var(--white);
    }
    
    section {
        box-shadow: none;
        border: 1px solid #ccc;
        page-break-inside: avoid;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    :root {
        --primary-color: #000080;
        --secondary-color: #4B0082;
        --text-dark: #000000;
        --text-light: #333333;
    }
}

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

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    :root {
        --background-color: #1a1a1a;
        --white: #2d2d2d;
        --text-dark: #ffffff;
        --text-light: #cccccc;
        --shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    }
}
