/* CSS Variables for consistent theming */
:root {
    --primary-color: #7868E6;
    --secondary-color: #B8B5FF;
    --accent-color: #FFB4B4;
    --light-bg: #EDEEF7;
    --lighter-bg: #E4FBFF;
    --white: #FFFFFF;
    --text-dark: #2D3748;
    --text-light: #4A5568;
    --border-color: #E2E8F0;
    --shadow-light: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-medium: 0 4px 8px rgba(0, 0, 0, 0.12);
    --shadow-heavy: 0 8px 16px rgba(0, 0, 0, 0.15);
    --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: var(--light-bg);
    /* Paper texture background */
    background-image: 
        radial-gradient(circle at 1px 1px, rgba(120, 104, 230, 0.1) 1px, transparent 0);
    background-size: 20px 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

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

/* Header */
.header {
    background: var(--white);
    box-shadow: var(--shadow-light);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 3px solid var(--primary-color);
}

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

.header__title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header__icon {
    font-size: 2rem;
    animation: pulse 2s infinite;
}

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

.header__nav {
    display: flex;
    gap: 0.5rem;
}

.nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem 1rem;
    border: none;
    background: transparent;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-light);
    font-size: 0.875rem;
}

.nav-btn:hover {
    background: var(--light-bg);
    color: var(--primary-color);
    transform: translateY(-2px);
}

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

.nav-btn__icon {
    font-size: 1.25rem;
}

.nav-btn__text {
    font-weight: 500;
}

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

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
}

.tab-content.active {
    display: block;
}

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

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.section-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
    position: relative;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 50px;
    height: 3px;
    background: var(--accent-color);
    border-radius: 2px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

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

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

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

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

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

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

.btn__icon {
    font-size: 1.125rem;
}

/* Supplements Grid */
.supplements-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.supplement-card {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-light);
    transition: var(--transition);
    border: 1px solid var(--border-color);
    position: relative;
}

.supplement-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-heavy);
}

.supplement-card__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.supplement-card__title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 0.25rem;
}

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

.supplement-card__actions {
    display: flex;
    gap: 0.5rem;
}

.supplement-card__info {
    margin-bottom: 1rem;
}

.supplement-card__frequency,
.supplement-card__time {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-light);
}

.supplement-card__notes {
    background: var(--light-bg);
    padding: 0.75rem;
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    margin-bottom: 1rem;
    border-left: 3px solid var(--secondary-color);
}

.supplement-card__status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    font-weight: 500;
}

.supplement-card__status--active {
    background: #D4F4DD;
    color: #22543D;
}

.supplement-card__status--inactive {
    background: #FED7D7;
    color: #742A2A;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: none;
}

.modal.is-open {
    display: block;
}

.modal__overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
}

.modal__container {
    background: var(--white);
    border-radius: var(--border-radius);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-heavy);
}

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

.modal__title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary-color);
}

.modal__close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-light);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--transition);
}

.modal__close:hover {
    background: var(--light-bg);
    color: var(--text-dark);
}

.modal__content {
    padding: 1.5rem;
}

.modal__footer {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 1.5rem;
}

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

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

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-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-textarea {
    resize: vertical;
    min-height: 100px;
}

.form-checkbox {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    font-size: 0.875rem;
}

.form-checkbox input {
    display: none;
}

.form-checkbox__checkmark {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

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

.form-checkbox input:checked + .form-checkbox__checkmark::after {
    content: '✓';
    color: var(--white);
    font-size: 12px;
    font-weight: bold;
}

/* Reminders */
.reminders-container {
    margin-bottom: 2rem;
}

.reminders-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.reminder-item {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-light);
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: var(--transition);
    border-left: 4px solid var(--primary-color);
}

.reminder-item:hover {
    box-shadow: var(--shadow-medium);
}

.reminder-item--completed {
    opacity: 0.6;
    border-left-color: var(--secondary-color);
}

.reminder-item__checkbox {
    width: 24px;
    height: 24px;
    border: 2px solid var(--primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.reminder-item__checkbox--checked {
    background: var(--primary-color);
    color: var(--white);
}

.reminder-item__content {
    flex: 1;
}

.reminder-item__title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 0.25rem;
}

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

.reminder-item__time {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.date-display {
    background: var(--primary-color);
    color: var(--white);
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    font-weight: 500;
}

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

/* History */
.history-filters {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

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

.stat-card {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-light);
    text-align: center;
    border-top: 3px solid var(--primary-color);
}

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

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

.history-timeline {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-light);
}

.timeline-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border-color);
}

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

.timeline-item__date {
    font-size: 0.875rem;
    color: var(--text-light);
    min-width: 100px;
}

.timeline-item__content {
    flex: 1;
}

.timeline-item__title {
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 0.25rem;
}

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

.timeline-item__status {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
}

.timeline-item__status--taken {
    background: #D4F4DD;
    color: #22543D;
}

.timeline-item__status--missed {
    background: #FED7D7;
    color: #742A2A;
}

/* FAQ */
.faq-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.faq-item {
    background: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-light);
    overflow: hidden;
}

.faq-item__question {
    width: 100%;
    padding: 1.5rem;
    border: none;
    background: none;
    text-align: left;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--primary-color);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: var(--transition);
}

.faq-item__question:hover {
    background: var(--light-bg);
}

.faq-item__question::after {
    content: '+';
    font-size: 1.5rem;
    font-weight: 300;
    transition: var(--transition);
}

.faq-item__question.active::after {
    transform: rotate(45deg);
}

.faq-item__answer {
    padding: 0 1.5rem;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.faq-item__answer.active {
    max-height: 500px;
    padding: 0 1.5rem 1.5rem;
}

.faq-item__answer p {
    color: var(--text-light);
    line-height: 1.6;
}

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

.footer__text {
    font-size: 0.875rem;
}

.footer__link {
    color: var(--white);
    text-decoration: underline;
    transition: var(--transition);
}

.footer__link:hover {
    color: var(--secondary-color);
}

/* Loading Spinner */
.loading-spinner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: none;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    z-index: 2000;
}

.loading-spinner.show {
    display: flex;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--light-bg);
    border-top: 4px solid var(--primary-color);
    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: 1500;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 300px;
}

.toast {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 1rem;
    box-shadow: var(--shadow-medium);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    animation: slideIn 0.3s ease;
    border-left: 4px solid var(--primary-color);
}

.toast--success {
    border-left-color: #48BB78;
}

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

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

.toast__icon {
    font-size: 1.25rem;
}

.toast__message {
    flex: 1;
    font-size: 0.875rem;
    color: var(--text-dark);
}

.toast__close {
    background: none;
    border: none;
    font-size: 1.125rem;
    cursor: pointer;
    color: var(--text-light);
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

/* Responsive Design */
@media (max-width: 768px) {
    .header .container {
        flex-direction: column;
        gap: 1rem;
    }
    
    .header__nav {
        width: 100%;
        justify-content: center;
    }
    
    .nav-btn {
        flex: 1;
        max-width: 100px;
    }
    
    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .supplements-grid {
        grid-template-columns: 1fr;
    }
    
    .history-filters {
        flex-direction: column;
    }
    
    .quick-actions {
        flex-direction: column;
    }
    
    .modal__container {
        margin: 1rem;
        max-height: calc(100vh - 2rem);
    }
    
    .toast-container {
        left: 20px;
        right: 20px;
        max-width: none;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 0.5rem;
    }
    
    .main {
        padding: 1rem 0;
    }
    
    .section-title {
        font-size: 1.5rem;
    }
    
    .supplement-card,
    .reminder-item {
        padding: 1rem;
    }
    
    .modal__header,
    .modal__content {
        padding: 1rem;
    }
    
    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
    }
}

/* Print Styles */
@media print {
    .header__nav,
    .modal,
    .toast-container,
    .loading-spinner,
    .btn {
        display: none !important;
    }
    
    .main {
        padding: 0;
    }
    
    .supplement-card,
    .reminder-item {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid var(--border-color);
    }
}

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

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