/* Variables */
:root {
    /* Color Scheme - Light Mode */
    --bg-primary: #f8f9fa;
    --bg-secondary: #ffffff;
    --text-primary: #212529;
    --text-secondary: #495057;
    --accent-primary: #3d5af1;
    --accent-secondary: #22c55e;
    --accent-tertiary: #e11d48;
    --border-color: #e9ecef;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --card-bg: #ffffff;
    --card-border: rgba(0, 0, 0, 0.1);
    --user-message-bg: #e6f2ff;
    --ai-message-bg: #f1f3f5;
    
    /* Animation Speed */
    --transition-fast: 0.2s;
    --transition-normal: 0.3s;
    --transition-slow: 0.5s;
    
    /* Fonts */
    --font-heading: 'Montserrat', sans-serif;
    --font-body: 'Poppins', sans-serif;
    
    /* Sizes */
    --header-height: 70px;
    --border-radius-sm: 8px;
    --border-radius-md: 12px;
    --border-radius-lg: 20px;
}

/* Dark Theme */
[data-theme="dark"] {
    --bg-primary: #111827;
    --bg-secondary: #1f2937;
    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
    --accent-primary: #4f46e5;
    --accent-secondary: #10b981;
    --accent-tertiary: #f43f5e;
    --border-color: #374151;
    --shadow-color: rgba(0, 0, 0, 0.3);
    --card-bg: #1f2937;
    --card-border: rgba(255, 255, 255, 0.1);
    --user-message-bg: #3a4a6b;
    --ai-message-bg: #2d3748;
}

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

html, body {
    height: 100%;
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    transition: background-color var(--transition-normal), color var(--transition-normal);
    overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    margin-bottom: 1rem;
    line-height: 1.2;
}

a {
    color: var(--accent-primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--accent-secondary);
}

button {
    cursor: pointer;
    font-family: var(--font-body);
    border: none;
    background: none;
    transition: all var(--transition-fast);
    outline: none;
}

ul {
    list-style-position: inside;
    padding-left: 0;
}

.hidden {
    display: none !important;
}

/* Animated Background */
.stars, .twinkling {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
}

.stars {
    background: #000 url('https://i.imgur.com/YKY28eT.png') repeat top center;
    opacity: 0.2;
}

[data-theme="dark"] .stars {
    opacity: 0.6;
}

.twinkling {
    background: transparent url('https://i.imgur.com/XYMF4ca.png') repeat top center;
    opacity: 0.1;
    animation: move-twinkle 200s linear infinite;
}

[data-theme="dark"] .twinkling {
    opacity: 0.3;
}

@keyframes move-twinkle {
    from {background-position: 0 0;}
    to {background-position: -10000px 5000px;}
}

/* Container Styles */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header Styles */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo i {
    font-size: 2rem;
    color: var(--accent-primary);
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-6px); }
    100% { transform: translateY(0px); }
}

.logo h1 {
    font-size: 1.5rem;
    margin-bottom: 0;
    background: linear-gradient(to right, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-fill-color: transparent;
}

.theme-toggle button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--bg-secondary);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px var(--shadow-color);
    transition: all var(--transition-fast);
}

.theme-toggle button:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px var(--shadow-color);
}

.theme-toggle i {
    font-size: 1.2rem;
    transition: all var(--transition-fast);
}

/* Main Content */
main {
    flex: 1;
}

.intro {
    text-align: center;
    margin-bottom: 3rem;
    padding: 0 1rem;
}

.intro h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
    background: linear-gradient(to right, var(--accent-primary), var(--accent-tertiary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-fill-color: transparent;
}

.intro p {
    font-size: 1.1rem;
    color: var(--text-secondary);
    max-width: 700px;
    margin: 0 auto;
}

/* Country Selector Styles */
.country-selector {
    background-color: var(--bg-secondary);
    border-radius: var(--border-radius-md);
    padding: 2rem;
    margin-bottom: 3rem;
    box-shadow: 0 4px 20px var(--shadow-color);
    transition: all var(--transition-normal);
}

.selection-container {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.select-group {
    flex: 1;
    min-width: 250px;
}

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

.custom-select {
    position: relative;
}

.custom-select select {
    appearance: none;
    width: 100%;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-size: 1rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.custom-select select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(61, 90, 241, 0.2);
}

.select-icon {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    pointer-events: none;
}

.journey-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    background-color: var(--accent-primary);
    color: white;
    border-radius: 50%;
    font-size: 1.2rem;
    box-shadow: 0 4px 12px rgba(61, 90, 241, 0.3);
    animation: pulse 2s infinite;
}

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

.generate-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(to right, var(--accent-primary), var(--accent-secondary));
    color: white;
    font-weight: 600;
    font-size: 1rem;
    padding: 1rem 2rem;
    border-radius: var(--border-radius-sm);
    transition: all var(--transition-fast);
    width: 100%;
    max-width: 300px;
    margin: 0 auto;
    position: relative;
    overflow: hidden;
}

.generate-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: all 0.6s;
}

.generate-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 15px rgba(61, 90, 241, 0.3);
}

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

.generate-btn.loading .btn-text {
    visibility: hidden;
}

.generate-btn.loading .loading-spinner {
    display: block;
}

.loading-spinner {
    display: none;
    position: absolute;
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Results Container Styles */
.results-container {
    background-color: var(--bg-secondary);
    border-radius: var(--border-radius-md);
    padding: 2rem;
    margin-bottom: 3rem;
    box-shadow: 0 4px 20px var(--shadow-color);
    animation: fade-in 0.5s ease-in-out;
}

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

.country-flag {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.country-flag img {
    width: 100px;
    height: 60px;
    object-fit: cover;
    border-radius: var(--border-radius-sm);
    box-shadow: 0 4px 8px var(--shadow-color);
    transition: transform var(--transition-fast);
}

.country-flag img:hover {
    transform: scale(1.05);
}

.country-flag h3 {
    font-size: 1.2rem;
    margin-bottom: 0;
}

.comparison-indicator {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.pulse-dot {
    width: 12px;
    height: 12px;
    background-color: var(--accent-primary);
    border-radius: 50%;
    animation: pulse-animation 2s infinite;
}

.line {
    height: 2px;
    width: 80px;
    background: linear-gradient(to right, var(--accent-primary), var(--accent-secondary));
}

@keyframes pulse-animation {
    0% { box-shadow: 0 0 0 0 rgba(61, 90, 241, 0.6); }
    70% { box-shadow: 0 0 0 10px rgba(61, 90, 241, 0); }
    100% { box-shadow: 0 0 0 0 rgba(61, 90, 241, 0); }
}

/* Tabs Styles */
.comparison-tabs {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
}

.tab-button {
    padding: 0.75rem 1.5rem;
    background-color: transparent;
    color: var(--text-secondary);
    font-weight: 500;
    border-radius: var(--border-radius-sm);
    transition: all var(--transition-fast);
}

.tab-button:hover {
    background-color: rgba(61, 90, 241, 0.1);
    color: var(--accent-primary);
}

.tab-button.active {
    background-color: var(--accent-primary);
    color: white;
}

.tab-content {
    animation: fade-in 0.3s ease-in-out;
}

/* Comparison Cards Styles */
.comparison-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.comparison-card {
    background-color: var(--card-bg);
    border-radius: var(--border-radius-md);
    border: 1px solid var(--card-border);
    padding: 1.5rem;
    box-shadow: 0 4px 12px var(--shadow-color);
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

.comparison-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 24px var(--shadow-color);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.card-header.centered {
    justify-content: center;
}

.card-header i {
    font-size: 1.5rem;
    color: var(--accent-primary);
}

.card-header h3 {
    font-size: 1.25rem;
    margin-bottom: 0;
}

.comparison-card ul, .food-card ul, .advice-list {
    list-style-type: none;
}

.comparison-card li, .food-card li {
    margin-bottom: 0.75rem;
    padding-left: 1.5rem;
    position: relative;
}

.comparison-card li:before, .food-card li:before {
    content: "";
    position: absolute;
    left: 0;
    top: 0.5rem;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--accent-primary);
}

.similarities li:before {
    background-color: var(--accent-secondary);
}

.differences li:before {
    background-color: var(--accent-tertiary);
}

/* Food Compatibility Styles */
.food-compatibility {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.compatibility-meter {
    text-align: center;
    margin-bottom: 1rem;
}

.meter-container {
    position: relative;
    height: 20px;
    background-color: var(--bg-primary);
    border-radius: 10px;
    overflow: hidden;
    margin: 1.5rem auto;
    max-width: 500px;
}

.meter-bg {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to right, #ef4444, #f59e0b, #10b981);
    opacity: 0.2;
}

.meter-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: linear-gradient(to right, #ef4444, #f59e0b, #10b981);
    width: 0%;
    transition: width 1s ease-in-out;
}

.meter-marker {
    position: absolute;
    top: -20px;
    transform: translateX(-50%);
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.meter-value {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-weight: bold;
    color: var(--text-primary);
    font-size: 0.85rem;
}

.food-description {
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
    margin: 0 auto;
    max-width: 700px;
}

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

.food-card {
    background-color: var(--card-bg);
    border-radius: var(--border-radius-md);
    border: 1px solid var(--card-border);
    padding: 1.5rem;
    box-shadow: 0 4px 12px var(--shadow-color);
}

/* Advice Styles */
.advice-container {
    background-color: var(--card-bg);
    border-radius: var(--border-radius-md);
    border: 1px solid var(--card-border);
    padding: 1.5rem;
    box-shadow: 0 4px 12px var(--shadow-color);
}

.advice-list li {
    margin-bottom: 1rem;
    padding-left: 2rem;
    position: relative;
    padding-bottom: 1rem;
    border-bottom: 1px dashed var(--border-color);
}

.advice-list li:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.advice-list li:before {
    content: "✓";
    position: absolute;
    left: 0;
    top: 0;
    color: var(--accent-secondary);
    font-weight: bold;
}

/* Chat Styles */
.country-chat {
    background-color: var(--bg-secondary);
    border-radius: var(--border-radius-md);
    padding: 2rem;
    margin-bottom: 3rem;
    box-shadow: 0 4px 20px var(--shadow-color);
}

.country-chat h3 {
    margin-bottom: 1.5rem;
    text-align: center;
    color: var(--accent-primary);
}

#chat-country-name {
    font-weight: 700;
    color: var(--accent-secondary);
}

.chat-container {
    display: flex;
    flex-direction: column;
    height: 400px;
    border-radius: var(--border-radius-md);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    background-color: var(--bg-primary);
}

.chat-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-secondary);
    text-align: center;
    padding: 0 2rem;
}

.chat-welcome i {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: var(--accent-primary);
    opacity: 0.7;
}

.message {
    display: flex;
    margin-bottom: 1.5rem;
    max-width: 80%;
}

.user-message {
    margin-left: auto;
    justify-content: flex-end;
}

.ai-message {
    margin-right: auto;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--accent-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 0.75rem;
}

.message-content {
    padding: 1rem;
    border-radius: var(--border-radius-md);
    box-shadow: 0 2px 8px var(--shadow-color);
}

.user-message .message-content {
    background-color: var(--user-message-bg);
    border-top-right-radius: 0;
}

.ai-message .message-content {
    background-color: var(--ai-message-bg);
    border-top-left-radius: 0;
}

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.typing-indicator span {
    display: inline-block;
    width: 8px;
    height: 8px;
    background-color: var(--accent-primary);
    border-radius: 50%;
    animation: typing-animation 1.5s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing-animation {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

.chat-input-wrapper {
    display: flex;
    padding: 1rem;
    background-color: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
}

.chat-input-wrapper input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-size: 1rem;
    outline: none;
    transition: all var(--transition-fast);
}

.chat-input-wrapper input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(61, 90, 241, 0.2);
}

.chat-input-wrapper input::placeholder {
    color: var(--text-secondary);
    opacity: 0.7;
}

.chat-input-wrapper button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin-left: 0.75rem;
    background-color: var(--accent-primary);
    color: white;
    border-radius: 50%;
    transition: all var(--transition-fast);
}

.chat-input-wrapper button:hover {
    background-color: var(--accent-secondary);
    transform: translateY(-2px);
}

.chat-input-wrapper button:disabled {
    background-color: var(--border-color);
    cursor: not-allowed;
    transform: none;
}

/* Background Process Status */
.background-status {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background-color: var(--bg-secondary);
    border-radius: var(--border-radius-md);
    border-left: 4px solid var(--accent-primary);
    box-shadow: 0 4px 12px var(--shadow-color);
    color: var(--text-secondary);
    font-size: 0.9rem;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s, transform 0.3s;
    z-index: 100;
}

.background-status.active {
    opacity: 1;
    transform: translateY(0);
}

.status-indicator .pulse-dot {
    width: 10px;
    height: 10px;
}

/* Error Message */
.error-message {
    background-color: #fee2e2;
    color: #b91c1c;
    border-radius: var(--border-radius-md);
    padding: 1rem;
    margin-bottom: 2rem;
    text-align: center;
    border-left: 4px solid #ef4444;
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

/* Footer Styles */
footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 0;
    margin-top: auto;
    border-top: 1px solid var(--border-color);
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.social-links {
    display: flex;
    gap: 1rem;
}

.social-links a {
    color: var(--text-secondary);
    transition: color var(--transition-fast);
}

.social-links a:hover {
    color: var(--accent-primary);
    transform: translateY(-3px);
}

.social-links i {
    font-size: 1.2rem;
}

/* Animations */
.animated-element {
    opacity: 0;
    transform: translateY(20px);
    animation: fade-in-up 0.6s ease-out forwards;
}

@keyframes fade-in-up {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Responsive Design */
@media screen and (max-width: 768px) {
    .selection-container {
        flex-direction: column;
        align-items: stretch;
    }
    
    .journey-arrow {
        transform: rotate(90deg);
        margin: 0.5rem 0;
    }
    
    .comparison-grid, .food-grid {
        grid-template-columns: 1fr;
    }
    
    .results-header {
        flex-direction: column;
        gap: 2rem;
    }
    
    .comparison-indicator {
        transform: rotate(90deg);
    }
    
    .intro h2 {
        font-size: 1.75rem;
    }
    
    .comparison-tabs {
        overflow-x: auto;
        padding-bottom: 0.5rem;
    }
    
    .tab-button {
        white-space: nowrap;
    }
    
    .logo h1 {
        font-size: 1.2rem;
    }
    
    .chat-container {
        height: 300px;
    }
    
    .message {
        max-width: 90%;
    }
    
    .background-status {
        bottom: 10px;
        right: 10px;
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb {
    background: var(--accent-primary);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-secondary);
}