* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #f5f5f5;
    --bg-secondary: #ffffff;
    --text-primary: #333333;
    --text-secondary: #7f8c8d;
    --text-dark: #2c3e50;
    --border-color: #ddd;
    --border-light: #e0e0e0;
    --card-bg: #f8f9fa;
}

/* Login Modal Styles */
.login-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fadeIn 0.3s ease;
}

.login-modal-content {
    background-color: var(--bg-secondary);
    border-radius: 12px;
    padding: 0;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

.login-modal-header {
    padding: 30px 30px 20px;
    border-bottom: 2px solid var(--border-light);
    text-align: center;
}

.login-modal-header h2 {
    color: var(--text-dark);
    font-size: 1.8rem;
    margin: 0;
}

.login-modal-body {
    padding: 30px;
}

#loginForm {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.login-form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.login-form-group label {
    font-weight: 600;
    color: var(--text-dark);
    font-size: 0.95rem;
}

.login-form-group input {
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    transition: border-color 0.3s ease;
}

.login-form-group input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.login-error {
    background-color: #fee;
    border: 1px solid #fcc;
    border-radius: 6px;
    padding: 12px;
    color: #c33;
    font-size: 0.9rem;
}

body.dark-mode .login-error {
    background-color: #4a2c2c;
    border-color: #8b4444;
    color: #ff9999;
}

.login-submit-btn {
    padding: 12px;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease;
    margin-top: 10px;
}

.login-submit-btn:hover {
    background-color: #2980b9;
}

.login-submit-btn:active {
    transform: scale(0.98);
}

/* Header Controls */
.header-controls {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-shrink: 0;
}

.logout-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 5px 10px;
    border-radius: 6px;
    transition: background-color 0.3s ease;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    title: 'Logout';
}

.logout-btn:hover {
    background-color: var(--card-bg);
}

body.dark-mode {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --text-primary: #e0e0e0;
    --text-secondary: #b0b0b0;
    --text-dark: #e8f5e9;
    --border-color: #444;
    --border-light: #555;
    --card-bg: #333333;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 30px;
}

.header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: nowrap;
    position: relative;
    width: 100%;
}

.theme-toggle {
    position: static;
    right: auto;
    top: auto;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 5px 10px;
    border-radius: 6px;
    transition: background-color 0.3s ease;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.theme-toggle:hover {
    background-color: var(--card-bg);
}

.theme-toggle::before {
    content: '🌙';
}

body.dark-mode .theme-toggle::before {
    content: '☀️';
    filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.3));
}

.header-logo {
    min-width: 80px;
    min-height: 80px;
    max-width: 120px;
    max-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-logo img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.header-text {
    flex: 1;
    min-width: 200px;
    text-align: center;
}

h1 {
    font-size: 2.5rem;
    color: var(--text-dark);
    margin-bottom: 10px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.upload-section {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
    transition: background-color 0.3s ease;
}

.file-input-wrapper {
    margin-bottom: 20px;
}

#fileInput {
    display: none;
}

.file-label {
    display: block;
    padding: 40px 20px;
    border: 2px dashed #3498db;
    border-radius: 8px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background-color: var(--card-bg);
}

.file-label:hover {
    background-color: var(--bg-primary);
    border-color: #2980b9;
}

body.dark-mode .file-label:hover {
    background-color: #2a3f5f;
}

#fileName {
    display: block;
    font-size: 1.1rem;
    color: var(--text-dark);
    margin-bottom: 8px;
}

.file-info {
    display: block;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.form-options {
    margin-bottom: 20px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 0.95rem;
}

.checkbox-label input[type="checkbox"] {
    margin-right: 10px;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.form-group {
    margin-bottom: 20px;
}

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

.form-group input[type="text"] {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

.form-group input[type="text"]:focus {
    outline: none;
    border-color: #3498db;
}

.submit-btn {
    width: 100%;
    padding: 15px;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.submit-btn:hover:not(:disabled) {
    background-color: #2980b9;
}

.submit-btn:disabled {
    background-color: var(--text-secondary);
    cursor: not-allowed;
}

.image-preview {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-light);
    text-align: center;
}

.image-preview h3 {
    font-size: 1.2rem;
    margin-bottom: 15px;
    color: var(--text-dark);
}

.image-preview img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 0 auto 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: block;
}

#imageInfo {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.progress-message {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 40px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.spinner {
    width: 50px;
    height: 50px;
    margin: 0 auto 20px;
    border: 4px solid var(--border-light);
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

body.dark-mode .spinner {
    border: 4px solid #444;
    border-top: 4px solid #5aa6ff;
}

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

.progress-message p {
    font-size: 1.1rem;
    color: var(--text-dark);
    margin-bottom: 5px;
}

.progress-note {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.error-message {
    background-color: #fee;
    border: 1px solid #fcc;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    color: #c33;
}

body.dark-mode .error-message {
    background-color: #4a2c2c;
    border-color: #8b4444;
    color: #ff9999;
}

.results-section {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: background-color 0.3s ease;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.results-section h2 {
    color: var(--text-dark);
    margin-bottom: 0;
    font-size: 1.8rem;
}

.analysis-time {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.brand-index {
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-secondary) 100%);
    border: 2px solid var(--border-light);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    text-align: center;
}

body.dark-mode .brand-index {
    background: linear-gradient(135deg, #2a3f5f 0%, #1f2937 100%);
    border-color: #5aa6ff;
}

.brand-index h3 {
    color: var(--text-dark);
    margin-bottom: 10px;
}

body.dark-mode .brand-index h3 {
    color: #5aa6ff;
}

.brand-index .percentage {
    font-size: 3rem;
    font-weight: bold;
    color: #4caf50;
}

body.dark-mode .brand-index .percentage {
    color: #5aa6ff;
}

.brand-index .details {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 10px;
}

.no-brands-message {
    color: var(--text-secondary);
    font-size: 1rem;
    margin-top: 15px;
    padding: 10px;
    text-align: center;
}

.analysis-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.analysis-card {
    background-color: var(--bg-primary);
    border-radius: 8px;
    padding: 20px;
    border: 1px solid var(--border-light);
}

.analysis-card h3 {
    color: var(--text-dark);
    margin-bottom: 15px;
    font-size: 1.3rem;
}

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

.analysis-card li {
    padding: 8px 0;
    border-bottom: 1px solid var(--border-light);
}

.analysis-card li:last-child {
    border-bottom: none;
}

.analysis-card strong {
    color: var(--text-dark);
}

.venue-details {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.detail-row {
    display: flex;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-light);
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-row .label {
    font-weight: 600;
    color: var(--text-dark);
    min-width: 140px;
}

.detail-row .value {
    color: var(--text-primary);
}

.producer-details {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.situation-label {
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 5px;
}

.situation-list {
    list-style: disc;
    margin-left: 20px;
    color: var(--text-primary);
}

.situation-list li {
    margin-bottom: 8px;
    border-bottom: none;
}

.recommendations {
    margin-top: 20px;
}

.recommendations h3 {
    color: var(--text-dark);
    margin-bottom: 15px;
    font-size: 1.4rem;
    text-align: center;
}

.recommendations-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 20px;
}

.recommendation-checkbox-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 15px;
    background-color: var(--bg-primary);
    border-radius: 8px;
    border: 1px solid var(--border-light);
    transition: all 0.3s ease;
}

.recommendation-checkbox-item:hover {
    background-color: var(--bg-secondary);
    border-color: #3498db;
}

body.dark-mode .recommendation-checkbox-item:hover {
    border-color: #5aa6ff;
}

.recommendation-checkbox-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin-top: 2px;
    cursor: pointer;
    flex-shrink: 0;
}

.recommendation-label {
    flex: 1;
    cursor: pointer;
}

.recommendation-title {
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 8px;
}

.recommendation-description {
    color: var(--text-primary);
    font-size: 0.95rem;
    margin-bottom: 8px;
    line-height: 1.5;
}

.recommendation-products {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 5px;
}

.recommendation-meta {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.confirm-btn {
    width: 100%;
    padding: 12px;
    background-color: #2c3e50;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 15px;
    transition: background-color 0.3s ease;
}

.confirm-btn:hover {
    background-color: #1a252f;
}

body.dark-mode .confirm-btn {
    background-color: #556270;
}

body.dark-mode .confirm-btn:hover {
    background-color: #68798e;
}

/* Modal styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-content {
    background-color: var(--bg-secondary);
    border-radius: 12px;
    padding: 0;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border-light);
}

.modal-header h2 {
    color: var(--text-dark);
    margin: 0;
    font-size: 1.5rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: var(--text-secondary);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.3s ease;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
    color: var(--text-primary);
    line-height: 1.6;
    font-size: 1rem;
}

.modal-footer {
    display: flex;
    gap: 10px;
    padding: 20px;
    border-top: 1px solid var(--border-light);
    justify-content: flex-end;
}

.modal-btn-confirm {
    padding: 10px 30px;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.modal-btn-confirm:hover {
    background-color: #2980b9;
}

body.dark-mode .modal-btn-confirm {
    background-color: #2980b9;
}

body.dark-mode .modal-btn-confirm:hover {
    background-color: #3498db;
}

.change-photo-btn {
    width: 100%;
    padding: 12px;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.change-photo-btn:hover {
    background-color: #2980b9;
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
        max-width: 100%;
    }

    header {
        margin-bottom: 20px;
    }

    .header-top {
        gap: 10px;
    }

    h1 {
        font-size: 1.8rem;
    }

    .subtitle {
        font-size: 0.95rem;
    }

    .upload-section {
        padding: 15px;
        margin-bottom: 15px;
    }

    .file-label {
        padding: 25px 15px;
    }

    #fileName {
        font-size: 1rem;
    }

    .file-info {
        font-size: 0.85rem;
    }

    .submit-btn {
        padding: 12px;
        font-size: 1rem;
    }

    .progress-message {
        padding: 20px;
    }

    .analysis-grid {
        grid-template-columns: 1fr;
    }

    .results-section {
        padding: 15px;
    }

    .results-section h2 {
        font-size: 1.4rem;
    }

    .brand-index .percentage {
        font-size: 2.5rem;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 8px;
    }

    header {
        margin-bottom: 15px;
    }

    .header-top {
        flex-direction: column;
        gap: 10px;
    }

    .header-logo {
        min-width: 60px;
        min-height: 60px;
    }

    h1 {
        font-size: 1.5rem;
    }

    .subtitle {
        font-size: 0.85rem;
    }

    .upload-section {
        padding: 12px;
        margin-bottom: 12px;
    }

    .file-label {
        padding: 20px 10px;
    }

    .form-options {
        margin-bottom: 15px;
    }

    .checkbox-label {
        font-size: 0.85rem;
    }

    .submit-btn {
        padding: 10px;
        font-size: 0.95rem;
    }

    .progress-message {
        padding: 15px;
    }

    .spinner {
        width: 40px;
        height: 40px;
    }

    .progress-message p {
        font-size: 0.95rem;
    }

    .analysis-card {
        padding: 15px;
    }

    .analysis-card h3 {
        font-size: 1.1rem;
    }

    .recommendation-item {
        padding: 12px;
    }
}
