/* CSS Variables for consistent theming */
:root {
    --primary-color: #7868E6;
    --secondary-color: #B8B5FF;
    --accent-color: #FFB4B4;
    --light-bg: #EDEEF7;
    --light-accent: #E4FBFF;
    --text-dark: #333333;
    --text-light: #666666;
    --white: #ffffff;
    --border-radius: 12px;
    --shadow: 0 4px 20px rgba(120, 104, 230, 0.15);
    --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;
}

body {
    font-family: var(--font-family);
    line-height: 1.6;
    color: var(--text-dark);
    background: var(--light-bg);
    /* Paper texture effect */
    background-image: 
        radial-gradient(circle at 20% 50%, rgba(120, 104, 230, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(184, 181, 255, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 40% 80%, rgba(255, 180, 180, 0.05) 0%, transparent 50%);
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.header {
    background: var(--white);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 20px;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    text-decoration: none;
}

.nav {
    display: flex;
    gap: 2rem;
}

.nav-link {
    text-decoration: none;
    color: var(--text-dark);
    font-weight: 500;
    transition: var(--transition);
    position: relative;
}

.nav-link:hover,
.nav-link.active {
    color: var(--primary-color);
}

.nav-link.active::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--primary-color);
}

/* Main Content */
.main {
    padding: 2rem 0;
}

/* Hero Section */
.hero {
    text-align: center;
    padding: 3rem 0;
    background: linear-gradient(135deg, var(--secondary-color), var(--light-accent));
    border-radius: var(--border-radius);
    margin-bottom: 3rem;
}

.hero h2 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: var(--text-dark);
}

.hero p {
    font-size: 1.2rem;
    color: var(--text-light);
    max-width: 600px;
    margin: 0 auto;
}

/* Cards */
.card {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

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

/* Forms */
.form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

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

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

.form-group input,
.form-group select,
.form-group textarea {
    padding: 0.75rem;
    border: 2px solid #e0e0e0;
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: var(--transition);
    background: var(--white);
}

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

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

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

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

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

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

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

.btn-accent:hover {
    background: #ff9999;
    transform: translateY(-2px);
}

.btn-success {
    background: #4CAF50;
    color: var(--white);
}

.btn-success:hover {
    background: #45a049;
    transform: translateY(-2px);
}

.btn-danger {
    background: #f44336;
    color: var(--white);
}

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

.btn-outline {
    background: transparent;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}

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

/* Camera Section */
.camera-section {
    margin: 3rem 0;
}

.camera-container {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--shadow);
}

.camera-header {
    text-align: center;
    margin-bottom: 2rem;
}

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

.week-info {
    color: var(--text-light);
    font-style: italic;
}

.camera-wrapper {
    max-width: 600px;
    margin: 0 auto;
}

.camera-preview {
    position: relative;
    width: 100%;
    max-width: 500px;
    margin: 0 auto 2rem;
    border-radius: var(--border-radius);
    overflow: hidden;
    background: #000;
}

#cameraVideo {
    width: 100%;
    height: auto;
    display: block;
}

#cameraCanvas {
    width: 100%;
    height: auto;
}

/* Positioning Guide */
.positioning-guide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.guide-outline {
    width: 60%;
    height: 80%;
    border: 3px dashed rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    position: relative;
}

.guide-outline::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    height: 60%;
    border: 2px dashed rgba(255, 255, 255, 0.6);
    border-radius: 50%;
}

.guide-instructions {
    position: absolute;
    bottom: 10%;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    color: white;
    background: rgba(0, 0, 0, 0.7);
    padding: 1rem;
    border-radius: var(--border-radius);
    font-size: 0.9rem;
}

.guide-instructions p {
    margin: 0.25rem 0;
}

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

/* Timer Display */
.timer-display {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 2rem;
    border-radius: 50%;
    font-size: 3rem;
    font-weight: bold;
    z-index: 10;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% { transform: translate(-50%, -50%) scale(1); }
    50% { transform: translate(-50%, -50%) scale(1.1); }
    100% { transform: translate(-50%, -50%) scale(1); }
}

/* Captured Photo */
.captured-photo {
    text-align: center;
    margin-top: 2rem;
}

.captured-photo h4 {
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.captured-photo img {
    max-width: 100%;
    height: auto;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
}

.photo-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* Timeline Section */
.timeline-section {
    margin: 3rem 0;
}

.timeline-section h3 {
    text-align: center;
    margin-bottom: 2rem;
    color: var(--primary-color);
}

.timeline-container {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

.timeline-scroll {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    padding: 1rem 0;
    min-height: 200px;
}

.timeline-scroll::-webkit-scrollbar {
    height: 8px;
}

.timeline-scroll::-webkit-scrollbar-track {
    background: var(--light-bg);
    border-radius: 4px;
}

.timeline-scroll::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}

.timeline-item {
    flex: 0 0 200px;
    text-align: center;
    background: var(--light-bg);
    border-radius: var(--border-radius);
    padding: 1rem;
    transition: var(--transition);
    cursor: pointer;
}

.timeline-item:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow);
}

.timeline-item img {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: var(--border-radius);
    margin-bottom: 0.5rem;
}

.timeline-item-info {
    font-size: 0.9rem;
}

.timeline-item-week {
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 0.25rem;
}

.timeline-item-date {
    color: var(--text-light);
    font-size: 0.8rem;
}

.timeline-placeholder {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-light);
    text-align: center;
    padding: 2rem;
}

.timeline-controls {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* Statistics Section */
.stats-section {
    margin: 3rem 0;
}

.stats-section h3 {
    text-align: center;
    margin-bottom: 2rem;
    color: var(--primary-color);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
}

.stat-card {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 2rem;
    text-align: center;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-5px);
}

.stat-card h4 {
    margin-bottom: 1rem;
    color: var(--text-dark);
}

.stat-card span {
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary-color);
}

/* Footer */
.footer {
    background: var(--text-dark);
    color: var(--white);
    text-align: center;
    padding: 2rem 0;
    margin-top: 4rem;
}

.footer p {
    margin: 0;
    font-size: 0.9rem;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    color: white;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-top: 5px solid 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: 1001;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.toast {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 1rem 1.5rem;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--primary-color);
    animation: slideIn 0.3s ease;
    max-width: 300px;
}

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

.toast.error {
    border-left-color: #f44336;
}

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

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

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 0 15px;
    }
    
    .hero h2 {
        font-size: 2rem;
    }
    
    .hero p {
        font-size: 1rem;
    }
    
    .card {
        padding: 1.5rem;
    }
    
    .camera-controls {
        flex-direction: column;
        align-items: center;
    }
    
    .camera-controls .btn {
        width: 100%;
        max-width: 300px;
    }
    
    .photo-actions {
        flex-direction: column;
        align-items: center;
    }
    
    .photo-actions .btn {
        width: 100%;
        max-width: 300px;
    }
    
    .timeline-controls {
        flex-direction: column;
        align-items: center;
    }
    
    .timeline-controls .btn {
        width: 100%;
        max-width: 300px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .header .container {
        flex-direction: column;
        gap: 1rem;
    }
    
    .nav {
        gap: 1rem;
    }
}

@media (max-width: 480px) {
    .hero {
        padding: 2rem 0;
    }
    
    .hero h2 {
        font-size: 1.5rem;
    }
    
    .card {
        padding: 1rem;
    }
    
    .timeline-item {
        flex: 0 0 150px;
    }
    
    .timeline-item img {
        height: 120px;
    }
    
    .toast-container {
        left: 20px;
        right: 20px;
    }
    
    .toast {
        max-width: none;
    }
}

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

/* Focus styles for keyboard navigation */
.btn:focus,
input:focus,
select:focus,
textarea:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --primary-color: #000080;
        --text-dark: #000000;
        --text-light: #333333;
    }
}
