/* CSS Variables for consistent theming */
:root {
    --primary-color: #7868E6;
    --secondary-color: #B8B5FF;
    --accent-color: #E4FBFF;
    --background-color: #EDEEF7;
    --error-color: #FFB4B4;
    --text-color: #333333;
    --text-light: #666666;
    --white: #ffffff;
    --shadow: 0 2px 10px rgba(120, 104, 230, 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;
}

body {
    font-family: var(--font-family);
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    
    /* 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(228, 251, 255, 0.05) 0%, transparent 50%);
    background-attachment: fixed;
}

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

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

.header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="paper" x="0" y="0" width="20" height="20" patternUnits="userSpaceOnUse"><circle cx="10" cy="10" r="0.5" fill="rgba(255,255,255,0.1)"/></pattern></defs><rect width="100" height="100" fill="url(%23paper)"/></svg>');
    opacity: 0.3;
}

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

.header__icon {
    font-size: 2rem;
    margin-right: 0.5rem;
}

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

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

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

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="cardpaper" x="0" y="0" width="10" height="10" patternUnits="userSpaceOnUse"><circle cx="5" cy="5" r="0.3" fill="rgba(120,104,230,0.02)"/></pattern></defs><rect width="100" height="100" fill="url(%23cardpaper)"/></svg>');
    pointer-events: none;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(120, 104, 230, 0.15);
}

.card__title {
    font-size: 1.5rem;
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    position: relative;
    z-index: 1;
}

/* Form Styles */
.form {
    position: relative;
    z-index: 1;
}

.form__group {
    margin-bottom: 1.5rem;
}

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

.form__input {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid transparent;
    border-radius: var(--border-radius);
    background-color: var(--accent-color);
    font-size: 1rem;
    transition: var(--transition);
    outline: none;
}

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

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

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

/* Button Styles */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: var(--transition);
    outline: none;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.btn:hover::before {
    left: 100%;
}

.btn--primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: var(--white);
}

.btn--primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(120, 104, 230, 0.3);
}

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

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

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

/* Analysis Section */
.analysis {
    position: relative;
    z-index: 1;
}

.analysis__placeholder {
    text-align: center;
    padding: 2rem;
    color: var(--text-light);
}

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

.analysis__metric {
    background: var(--accent-color);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    text-align: center;
    border: 2px solid transparent;
    transition: var(--transition);
}

.analysis__metric:hover {
    border-color: var(--primary-color);
}

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

.analysis__metric-label {
    font-size: 0.875rem;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.analysis__status {
    padding: 1rem;
    border-radius: var(--border-radius);
    text-align: center;
    font-weight: 600;
    margin-top: 1rem;
}

.analysis__status--adequate {
    background: linear-gradient(135deg, #4CAF50 0%, #8BC34A 100%);
    color: var(--white);
}

.analysis__status--insufficient {
    background: linear-gradient(135deg, #FF9800 0%, #FFC107 100%);
    color: var(--white);
}

.analysis__status--excess {
    background: linear-gradient(135deg, #2196F3 0%, #03A9F4 100%);
    color: var(--white);
}

/* History Section */
.history-controls {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.history {
    position: relative;
    z-index: 1;
}

.history__placeholder {
    text-align: center;
    padding: 2rem;
    color: var(--text-light);
}

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

.history__item:hover {
    background: var(--white);
    box-shadow: var(--shadow);
}

.history__item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.history__item-time {
    font-weight: 600;
    color: var(--primary-color);
}

.history__item-volume {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-color);
}

.history__item-details {
    font-size: 0.875rem;
    color: var(--text-light);
}

.history__item-delete {
    background: var(--error-color);
    color: var(--white);
    border: none;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    transition: var(--transition);
}

.history__item-delete:hover {
    background: #ff8a8a;
}

/* Chart Section */
.chart-container {
    position: relative;
    height: 400px;
    margin-top: 1rem;
}

#production-chart {
    max-width: 100%;
    height: auto;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

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

.footer__text {
    font-size: 0.875rem;
}

.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;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    color: var(--white);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    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); }
}

/* Notification System */
.notification-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    max-width: 400px;
}

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

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

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

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

.notification__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) {
    .container {
        padding: 0 15px;
    }
    
    .header__title {
        font-size: 2rem;
    }
    
    .header__icon {
        font-size: 1.5rem;
    }
    
    .card {
        padding: 1.5rem;
    }
    
    .analysis__result {
        grid-template-columns: 1fr;
    }
    
    .history-controls {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
        text-align: center;
    }
    
    .history__item-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .chart-container {
        height: 300px;
    }
    
    .notification-container {
        left: 20px;
        right: 20px;
        max-width: none;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 1.5rem 0;
    }
    
    .header__title {
        font-size: 1.5rem;
    }
    
    .main {
        padding: 1rem 0;
    }
    
    .card {
        padding: 1rem;
        margin-bottom: 1rem;
    }
    
    .form__input {
        padding: 0.5rem;
    }
    
    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }
}

/* Print Styles */
@media print {
    .header,
    .footer,
    .history-controls,
    .loading-overlay,
    .notification-container {
        display: none;
    }
    
    .card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
    }
    
    body {
        background: white;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    :root {
        --primary-color: #0000ff;
        --secondary-color: #000080;
        --text-color: #000000;
        --background-color: #ffffff;
    }
}

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

/* Focus Styles for Accessibility */
.form__input:focus,
.btn:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Screen Reader Only */
.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;
}
