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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #EDEEF7 0%, #E4FBFF 100%);
    min-height: 100vh;
    color: #333;
    position: relative;
}

/* Paper Texture Effect */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    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%),
        radial-gradient(circle at 40% 40%, rgba(255, 180, 180, 0.05) 0%, transparent 50%);
    pointer-events: none;
    z-index: -1;
}

.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    min-height: calc(100vh - 80px);
}

/* Header Styles */
.header {
    text-align: center;
    margin-bottom: 40px;
    background: rgba(255, 255, 255, 0.9);
    padding: 30px;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(120, 104, 230, 0.1);
    backdrop-filter: blur(10px);
}

.app-title {
    font-size: 2.5rem;
    color: #7868E6;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.app-subtitle {
    font-size: 1.1rem;
    color: #666;
    margin-bottom: 30px;
}

/* Navigation */
.nav {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.nav-btn {
    background: linear-gradient(135deg, #B8B5FF, #7868E6);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    font-weight: 500;
    box-shadow: 0 4px 15px rgba(120, 104, 230, 0.3);
}

.nav-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(120, 104, 230, 0.4);
}

.nav-btn.active {
    background: linear-gradient(135deg, #7868E6, #B8B5FF);
    box-shadow: 0 6px 20px rgba(120, 104, 230, 0.5);
}

/* Section Management */
.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); }
}

/* Calculator Styles */
.calculator-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    align-items: start;
}

.input-card, .results-card {
    background: rgba(255, 255, 255, 0.95);
    padding: 30px;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

.input-card h2, .results-card h2 {
    color: #7868E6;
    margin-bottom: 25px;
    font-size: 1.5rem;
}

.input-group {
    margin-bottom: 25px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #555;
}

.input-group input, .input-group select, .input-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #EDEEF7;
    border-radius: 12px;
    font-size: 16px;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.8);
}

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

/* Slider Styles */
.slider {
    -webkit-appearance: none;
    appearance: none;
    height: 8px;
    background: linear-gradient(to right, #B8B5FF, #7868E6);
    border-radius: 4px;
    outline: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    background: #7868E6;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(120, 104, 230, 0.3);
}

.slider::-moz-range-thumb {
    width: 24px;
    height: 24px;
    background: #7868E6;
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 10px rgba(120, 104, 230, 0.3);
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 0.9rem;
    color: #666;
}

/* Button Styles */
.calculate-btn, .save-btn, .add-btn, .export-btn {
    background: linear-gradient(135deg, #7868E6, #B8B5FF);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(120, 104, 230, 0.3);
    width: 100%;
}

.calculate-btn:hover, .save-btn:hover, .add-btn:hover, .export-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(120, 104, 230, 0.4);
}

.clear-btn, .cancel-btn {
    background: linear-gradient(135deg, #FFB4B4, #ff9999);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
}

.clear-btn:hover, .cancel-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(255, 180, 180, 0.4);
}

/* Results Display */
.portion-item {
    background: rgba(228, 251, 255, 0.5);
    padding: 15px;
    border-radius: 12px;
    margin-bottom: 15px;
    border-left: 4px solid #7868E6;
}

.portion-item h4 {
    color: #7868E6;
    margin-bottom: 8px;
}

.portion-item p {
    color: #555;
    margin-bottom: 5px;
}

.conversion-note {
    font-size: 0.9rem;
    color: #888;
    font-style: italic;
}

/* Recipes Section */
.recipes-container {
    max-width: 1000px;
    margin: 0 auto;
}

.age-filter {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.filter-btn {
    background: rgba(255, 255, 255, 0.8);
    border: 2px solid #EDEEF7;
    padding: 10px 20px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #666;
}

.filter-btn.active, .filter-btn:hover {
    background: linear-gradient(135deg, #B8B5FF, #7868E6);
    color: white;
    border-color: #7868E6;
}

.recipes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 25px;
}

.recipe-card {
    background: rgba(255, 255, 255, 0.95);
    padding: 25px;
    border-radius: 20px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.recipe-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.15);
}

.recipe-card h3 {
    color: #7868E6;
    margin-bottom: 15px;
    font-size: 1.3rem;
}

.recipe-meta {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    font-size: 0.9rem;
    color: #666;
}

.recipe-ingredients, .recipe-instructions {
    margin-bottom: 15px;
}

.recipe-ingredients h4, .recipe-instructions h4 {
    color: #555;
    margin-bottom: 8px;
    font-size: 1rem;
}

.recipe-ingredients ul, .recipe-instructions ol {
    padding-left: 20px;
}

.recipe-ingredients li, .recipe-instructions li {
    margin-bottom: 5px;
    color: #666;
}

/* History Section */
.history-container {
    max-width: 1000px;
    margin: 0 auto;
}

.history-controls {
    display: flex;
    justify-content: space-between;
    margin-bottom: 30px;
    gap: 15px;
}

.history-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.history-item {
    background: rgba(255, 255, 255, 0.95);
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
    border-left: 4px solid #7868E6;
}

.history-item h4 {
    color: #7868E6;
    margin-bottom: 10px;
}

.history-meta {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 10px;
}

.history-portions {
    font-size: 0.9rem;
    color: #555;
}

/* Profile Section */
.profiles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.profile-card {
    background: rgba(255, 255, 255, 0.95);
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
    position: relative;
}

.profile-card h4 {
    color: #7868E6;
    margin-bottom: 15px;
    font-size: 1.2rem;
}

.profile-info {
    margin-bottom: 15px;
}

.profile-info p {
    margin-bottom: 5px;
    color: #666;
}

.profile-actions {
    display: flex;
    gap: 10px;
}

.edit-btn, .delete-btn, .select-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.edit-btn, .select-btn {
    background: linear-gradient(135deg, #B8B5FF, #7868E6);
    color: white;
}

.delete-btn {
    background: linear-gradient(135deg, #FFB4B4, #ff9999);
    color: white;
}

.edit-btn:hover, .select-btn:hover, .delete-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
}

.modal-content {
    background: white;
    margin: 5% auto;
    padding: 30px;
    border-radius: 20px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    position: relative;
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    position: absolute;
    right: 20px;
    top: 15px;
}

.close:hover {
    color: #7868E6;
}

.modal-buttons {
    display: flex;
    gap: 15px;
    margin-top: 25px;
}

.modal-buttons button {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 500;
}

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

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #EDEEF7;
    border-top: 4px solid #7868E6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Toast Notifications */
.toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: linear-gradient(135deg, #7868E6, #B8B5FF);
    color: white;
    padding: 15px 25px;
    border-radius: 25px;
    box-shadow: 0 6px 20px rgba(120, 104, 230, 0.4);
    transform: translateX(400px);
    transition: transform 0.3s ease;
    z-index: 1000;
    max-width: 300px;
}

.toast.show {
    transform: translateX(0);
}

.toast.error {
    background: linear-gradient(135deg, #FFB4B4, #ff9999);
}

/* FAQ Styles */
.faq-section {
    max-width: 800px;
    margin: 0 auto;
}

.faq-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.faq-item {
    border-bottom: 1px solid #EDEEF7;
    margin-bottom: 20px;
    padding-bottom: 20px;
}

.faq-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.faq-question {
    color: #7868E6;
    cursor: pointer;
    padding: 15px 0;
    position: relative;
    transition: color 0.3s ease;
}

.faq-question:hover {
    color: #B8B5FF;
}

.faq-question::after {
    content: '+';
    position: absolute;
    right: 0;
    font-size: 1.5rem;
    transition: transform 0.3s ease;
}

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

.faq-answer {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.faq-item.active .faq-answer {
    max-height: 200px;
}

.faq-answer p {
    padding: 15px 0;
    color: #666;
    line-height: 1.6;
}

/* Footer */
.footer {
    background: rgba(255, 255, 255, 0.9);
    text-align: center;
    padding: 20px;
    margin-top: 40px;
    border-radius: 15px 15px 0 0;
    box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.1);
}

.footer p {
    color: #666;
    font-size: 0.9rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .app-container {
        padding: 15px;
    }
    
    .app-title {
        font-size: 2rem;
    }
    
    .calculator-container {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .nav {
        flex-direction: column;
        align-items: center;
    }
    
    .nav-btn {
        width: 200px;
        text-align: center;
    }
    
    .history-controls {
        flex-direction: column;
    }
    
    .age-filter {
        justify-content: center;
    }
    
    .modal-content {
        width: 95%;
        margin: 10% auto;
        padding: 20px;
    }
    
    .toast {
        right: 15px;
        bottom: 15px;
        max-width: calc(100vw - 30px);
    }
}

@media (max-width: 480px) {
    .input-card, .results-card, .recipe-card, .history-item, .profile-card {
        padding: 20px;
    }
    
    .recipes-grid, .history-grid, .profiles-grid {
        grid-template-columns: 1fr;
    }
    
    .profile-actions {
        flex-direction: column;
    }
    
    .modal-buttons {
        flex-direction: column;
    }
}

/* Print Styles */
@media print {
    .nav, .footer, .modal, .toast, .loading {
        display: none !important;
    }
    
    .app-container {
        max-width: none;
        padding: 0;
    }
    
    .section {
        display: block !important;
    }
    
    .recipe-card, .history-item {
        break-inside: avoid;
        margin-bottom: 20px;
    }
}

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

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .input-group input, .input-group select, .input-group textarea {
        border-width: 3px;
    }
    
    .nav-btn, .calculate-btn, .save-btn {
        border: 2px solid #000;
    }
}

/* Focus Indicators */
button:focus, input:focus, select:focus, textarea:focus {
    outline: 3px solid rgba(120, 104, 230, 0.5);
    outline-offset: 2px;
}

/* Loading State for Buttons */
.btn-loading {
    position: relative;
    color: transparent !important;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    top: 50%;
    left: 50%;
    margin-left: -10px;
    margin-top: -10px;
    border: 2px solid transparent;
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
