/* CSS Custom Properties */
:root {
    --primary-color: #7868E6;
    --secondary-color: #B8B5FF;
    --accent-color: #FFB4B4;
    --background-color: #EDEEF7;
    --surface-color: #E4FBFF;
    --text-primary: #2D3748;
    --text-secondary: #4A5568;
    --text-muted: #718096;
    --border-color: #E2E8F0;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    --border-radius: 8px;
    --transition: all 0.3s ease;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--background-color);
    background-image: 
        radial-gradient(circle at 20% 80%, rgba(120, 104, 230, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(184, 181, 255, 0.1) 0%, transparent 50%);
    min-height: 100vh;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

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

.header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        repeating-linear-gradient(
            45deg,
            transparent,
            transparent 2px,
            rgba(255, 255, 255, 0.1) 2px,
            rgba(255, 255, 255, 0.1) 4px
        );
    pointer-events: none;
}

.header__title {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.header__subtitle {
    font-size: 1.2rem;
    opacity: 0.9;
}

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

.nav__list {
    display: flex;
    list-style: none;
    justify-content: center;
    flex-wrap: wrap;
}

.nav__item {
    margin: 0 1rem;
}

.nav__link {
    display: block;
    padding: 1rem 1.5rem;
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 500;
    transition: var(--transition);
    border-bottom: 3px solid transparent;
}

.nav__link:hover,
.nav__link--active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

/* Main Content */
.main {
    padding: 2rem 0;
    min-height: calc(100vh - 200px);
}

.section {
    display: none;
    animation: fadeIn 0.5s ease-in-out;
}

.section--active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.section__title {
    font-size: 2rem;
    color: var(--text-primary);
    margin-bottom: 2rem;
    text-align: center;
}

/* Card */
.card {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    padding: 2rem;
    margin-bottom: 2rem;
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
}

/* Form Styles */
.form {
    max-width: 600px;
    margin: 0 auto;
}

.form__group {
    margin-bottom: 2rem;
}

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

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

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

.form__input:invalid {
    border-color: var(--accent-color);
}

.form__error {
    display: block;
    color: var(--accent-color);
    font-size: 0.875rem;
    margin-top: 0.25rem;
    min-height: 1.2rem;
}

/* Intensity Scale */
.intensity-scale {
    background: var(--surface-color);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    border: 2px solid var(--border-color);
}

.intensity-scale__labels {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.intensity-scale__buttons {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.intensity-radio {
    display: none;
}

.intensity-label {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    background: white;
    font-weight: 600;
}

.intensity-radio:checked + .intensity-label {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: scale(1.1);
}

.intensity-label:hover {
    border-color: var(--primary-color);
    transform: scale(1.05);
}

/* Tags Container */
.tags-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.tag-option {
    position: relative;
}

.tag-checkbox {
    display: none;
}

.tag-label {
    display: block;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: white;
    font-weight: 500;
}

.tag-checkbox:checked + .tag-label {
    background: var(--secondary-color);
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-2px);
}

.tag-label:hover {
    border-color: var(--primary-color);
    transform: translateY(-1px);
}

/* Radio Group */
.radio-group {
    display: flex;
    gap: 2rem;
    margin-top: 0.5rem;
}

.radio-input {
    display: none;
}

.radio-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-weight: 500;
    position: relative;
    padding-left: 2rem;
}

.radio-label::before {
    content: '';
    position: absolute;
    left: 0;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    background: white;
    transition: var(--transition);
}

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

.radio-input:checked + .radio-label::after {
    content: '';
    position: absolute;
    left: 6px;
    top: 6px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: white;
}

/* Buttons */
.btn {
    display: inline-block;
    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;
    text-align: center;
    min-width: 120px;
}

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

.btn--primary:hover {
    background: #6B5CE6;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

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

.btn--secondary:hover {
    background: #A8A5FF;
    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: white;
}

/* Chart Container */
.chart-container {
    position: relative;
    height: 300px;
    margin: 2rem 0;
    background: white;
    border-radius: var(--border-radius);
    padding: 1rem;
    box-shadow: var(--shadow-sm);
}

/* History Controls */
.history-controls {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin: 2rem 0;
    flex-wrap: wrap;
}

/* History List */
.history-list {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--surface-color);
}

.history-item {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: var(--transition);
}

.history-item:hover {
    background: white;
}

.history-item:last-child {
    border-bottom: none;
}

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

.history-item__intensity {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.intensity-badge {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
}

.intensity-badge--0 { background: #E2E8F0; color: var(--text-secondary); }
.intensity-badge--1 { background: #68D391; }
.intensity-badge--2 { background: #F6E05E; }
.intensity-badge--3 { background: #F6AD55; }
.intensity-badge--4 { background: #FC8181; }
.intensity-badge--5 { background: #E53E3E; }

.history-item__triggers {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
}

.trigger-tag {
    background: var(--secondary-color);
    color: var(--primary-color);
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

/* Tips Container */
.tips-container {
    margin-bottom: 2rem;
}

.tip-card {
    background: var(--surface-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border-left: 4px solid var(--primary-color);
}

.tip-card h3,
.tip-card h4 {
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.tip-card ul {
    list-style: none;
    padding-left: 0;
}

.tip-card li {
    padding: 0.5rem 0;
    position: relative;
    padding-left: 1.5rem;
}

.tip-card li::before {
    content: '✓';
    position: absolute;
    left: 0;
    color: var(--primary-color);
    font-weight: 600;
}

.general-tips {
    display: grid;
    gap: 1.5rem;
}

.general-tips h3 {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--text-primary);
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

/* Messages */
.message {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 1rem 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    display: none;
    align-items: center;
    gap: 1rem;
    min-width: 300px;
    animation: slideIn 0.3s ease-out;
}

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

.message--success {
    background: #C6F6D5;
    color: #22543D;
    border: 1px solid #9AE6B4;
}

.message--error {
    background: #FED7D7;
    color: #742A2A;
    border: 1px solid #FC8181;
}

.message__close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: inherit;
    padding: 0;
    margin-left: auto;
}

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

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-overlay p {
    color: white;
    font-size: 1.1rem;
}

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

.footer__text {
    opacity: 0.8;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 0 0.5rem;
    }
    
    .header__title {
        font-size: 2rem;
    }
    
    .header__subtitle {
        font-size: 1rem;
    }
    
    .nav__list {
        flex-direction: column;
        align-items: center;
    }
    
    .nav__item {
        margin: 0;
        width: 100%;
        text-align: center;
    }
    
    .nav__link {
        padding: 0.75rem 1rem;
    }
    
    .card {
        padding: 1rem;
    }
    
    .intensity-scale__labels {
        font-size: 0.75rem;
    }
    
    .intensity-label {
        width: 35px;
        height: 35px;
        font-size: 0.875rem;
    }
    
    .tags-container {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
        gap: 0.5rem;
    }
    
    .tag-label {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }
    
    .radio-group {
        flex-direction: column;
        gap: 1rem;
    }
    
    .history-controls {
        flex-direction: column;
        align-items: center;
    }
    
    .history-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .message {
        left: 10px;
        right: 10px;
        min-width: auto;
    }
    
    .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    .history-controls .btn {
        width: auto;
        min-width: 140px;
    }
}

@media (max-width: 480px) {
    .intensity-scale__labels {
        display: none;
    }
    
    .intensity-label {
        width: 30px;
        height: 30px;
        font-size: 0.75rem;
    }
    
    .section__title {
        font-size: 1.5rem;
    }
    
    .chart-container {
        height: 250px;
    }
}

/* Print Styles */
@media print {
    .navigation,
    .btn,
    .message,
    .loading-overlay {
        display: none !important;
    }
    
    .header {
        background: none !important;
        color: black !important;
    }
    
    .card {
        box-shadow: none !important;
        border: 1px solid #ccc !important;
    }
    
    body {
        background: white !important;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    :root {
        --text-primary: #000;
        --text-secondary: #333;
        --border-color: #000;
        --primary-color: #0066cc;
        --secondary-color: #0080ff;
    }
    
    .btn {
        border: 2px solid currentColor;
    }
}

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