/* CalCounter - Food Calorie Estimation App Styles */

/* Base Styles */
:root {
    --primary-color: #4285f4;
    --primary-dark: #3367d6;
    --secondary-color: #34a853;
    --secondary-dark: #2e7d32;
    --danger-color: #ea4335;
    --danger-dark: #c62828;
    --text-color: #333;
    --light-text: #757575;
    --border-color: #ddd;
    --light-bg: #f5f5f5;
    --white: #fff;
    --shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    --border-radius: 8px;
    --transition: all 0.3s ease;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--light-bg);
    padding-bottom: 2rem;
}

.container {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    padding: 0 1rem;
}

h1, h2, h3, h4 {
    margin-bottom: 1rem;
    line-height: 1.2;
}

a {
    color: var(--primary-color);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

img {
    max-width: 100%;
    height: auto;
}

/* Header */
header {
    background-color: var(--primary-color);
    color: var(--white);
    padding: 1rem 0;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    margin: 0;
    font-size: 1.8rem;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    background-color: var(--primary-color);
    color: var(--white);
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 1rem;
    transition: var(--transition);
    text-align: center;
}

.btn:hover {
    background-color: var(--primary-dark);
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background-color: var(--primary-color);
}

.btn-primary:hover {
    background-color: var(--primary-dark);
}

.btn-secondary {
    background-color: var(--light-text);
}

.btn-secondary:hover {
    background-color: #616161;
}

.btn-success {
    background-color: var(--secondary-color);
}

.btn-success:hover {
    background-color: var(--secondary-dark);
}

.btn-danger {
    background-color: var(--danger-color);
}

.btn-danger:hover {
    background-color: var(--danger-dark);
}

.btn-logout {
    background-color: transparent;
    border: 1px solid var(--white);
}

.btn-logout:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.btn-large {
    padding: 0.75rem 1.5rem;
    font-size: 1.1rem;
}

.btn-small {
    padding: 0.25rem 0.5rem;
    font-size: 0.9rem;
}

/* Sections */
section {
    background-color: var(--white);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow);
}

section h2 {
    margin-top: 0;
    color: var(--primary-color);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

/* Login Section */
.login-section {
    text-align: center;
    padding: 2rem;
}

.login-section p {
    margin-bottom: 1.5rem;
    color: var(--light-text);
}

.login-form {
    max-width: 400px;
    margin: 0 auto 1.5rem;
    padding: 1.5rem;
    background-color: var(--light-bg);
    border-radius: var(--border-radius);
    text-align: left;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 1rem;
}

.login-form button {
    width: 100%;
    margin-top: 1rem;
}

.login-info {
    margin-top: 1rem;
    color: var(--light-text);
}

.error-message {
    color: var(--danger-color);
    background-color: rgba(234, 67, 53, 0.1);
    padding: 0.75rem;
    border-radius: var(--border-radius);
    margin: 1rem auto;
    max-width: 400px;
}

/* Upload Section */
.image-input-container {
    margin: 1.5rem 0;
}

#preview-container {
    margin-bottom: 1rem;
    text-align: center;
}

#image-preview {
    max-height: 300px;
    border-radius: var(--border-radius);
    margin-bottom: 0.5rem;
}

#upload-options {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

@media (max-width: 480px) {
    #upload-options {
        flex-direction: column;
    }
}

.hint-container {
    margin-bottom: 1.5rem;
}

.hint-container label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.hint-container input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 1rem;
}

/* API Key Container */
.api-key-container {
    background-color: var(--light-bg);
    padding: 1rem;
    border-radius: var(--border-radius);
    margin-bottom: 1.5rem;
}

.api-selector {
    margin-bottom: 1rem;
}

.api-selector label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.api-selector select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 1rem;
    background-color: var(--white);
}

.api-key-input {
    margin-bottom: 1rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.api-key-input label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    width: 100%;
}

.api-key-input input {
    flex: 1;
    min-width: 200px;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 1rem;
}

.warning {
    color: var(--danger-color);
    margin-top: 0.5rem;
    font-size: 0.9rem;
}

#calculate-btn {
    width: 100%;
    margin-top: 1rem;
}

/* Results Section */
.results-section {
    border: 2px solid var(--primary-color);
}

.calories-display {
    text-align: center;
    margin: 1.5rem 0;
    padding: 1rem;
    background-color: var(--light-bg);
    border-radius: var(--border-radius);
}

.calories-value {
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--primary-color);
}

.ai-response {
    margin-bottom: 1.5rem;
}

.ai-response h3 {
    margin-bottom: 0.5rem;
}

#ai-response-content {
    background-color: var(--light-bg);
    padding: 1rem;
    border-radius: var(--border-radius);
    white-space: pre-line;
}

.action-buttons {
    display: flex;
    gap: 1rem;
}

@media (max-width: 480px) {
    .action-buttons {
        flex-direction: column;
    }
}

/* History Section */
.history-entries {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
}

.history-entry {
    background-color: var(--white);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.history-entry:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.entry-image {
    height: 150px;
    overflow: hidden;
}

.entry-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.entry-details {
    padding: 1rem;
}

.entry-calories {
    font-weight: bold;
    font-size: 1.2rem;
    color: var(--primary-color);
}

.entry-hint {
    margin: 0.5rem 0;
    color: var(--text-color);
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.entry-date {
    color: var(--light-text);
    font-size: 0.8rem;
    margin-bottom: 0.5rem;
}

.no-entries, .loading, .error {
    text-align: center;
    padding: 2rem;
    color: var(--light-text);
}

.error {
    color: var(--danger-color);
}

/* Modal */
.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;
}

.modal-content {
    background-color: var(--white);
    border-radius: var(--border-radius);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.modal-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--light-text);
}

.modal-body {
    padding: 1rem;
}

.entry-image-large {
    text-align: center;
    margin-bottom: 1rem;
}

.entry-image-large img {
    max-height: 300px;
    border-radius: var(--border-radius);
}

.entry-calories-large {
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary-color);
    text-align: center;
    margin-bottom: 0.5rem;
}

.entry-hint-large {
    text-align: center;
    margin-bottom: 0.5rem;
}

.entry-date-large {
    text-align: center;
    color: var(--light-text);
    margin-bottom: 1rem;
}

.entry-response {
    background-color: var(--light-bg);
    padding: 1rem;
    border-radius: var(--border-radius);
    margin-top: 1rem;
}

.entry-response h4 {
    margin-top: 0;
    margin-bottom: 0.5rem;
}

.entry-response-content {
    white-space: pre-line;
}

.modal-footer {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
}

/* Notifications */
.notification {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 1rem;
    border-radius: var(--border-radius);
    background-color: var(--secondary-color);
    color: var(--white);
    box-shadow: var(--shadow);
    z-index: 1000;
    animation: slideIn 0.3s ease-out;
}

.notification.error {
    background-color: var(--danger-color);
}

.notification.fade-out {
    animation: fadeOut 0.5s ease-out forwards;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Footer */
footer {
    text-align: center;
    padding: 1rem 0;
    color: var(--light-text);
    font-size: 0.9rem;
}

/* Forced Colors Mode Support (replacing -ms-high-contrast) */
@media (forced-colors: active) {
    /* General button styling for forced colors mode */
    button,
    .btn,
    .g_id_signin div[role="button"] {
        forced-color-adjust: none;
        background-color: ButtonFace !important;
        color: ButtonText !important;
        border-color: ButtonText !important;
    }
    
    /* Focus states */
    button:focus,
    .btn:focus,
    .g_id_signin div[role="button"]:focus {
        outline: 2px solid ButtonText !important;
    }
    
    /* Hover states */
    button:hover,
    .btn:hover,
    .g_id_signin div[role="button"]:hover {
        background-color: Highlight !important;
        color: HighlightText !important;
    }
    
    /* Active states */
    button:active,
    .btn:active,
    .g_id_signin div[role="button"]:active {
        background-color: ButtonText !important;
        color: ButtonFace !important;
    }
    
    /* Links */
    a {
        color: LinkText !important;
    }
    
    a:visited {
        color: VisitedText !important;
    }
    
    a:hover, a:focus {
        color: HighlightText !important;
        background-color: Highlight !important;
    }
    
    /* Form elements */
    input, select, textarea {
        background-color: Field !important;
        color: FieldText !important;
        border: 1px solid ButtonText !important;
    }
    
    /* Disabled elements */
    button:disabled,
    .btn:disabled,
    input:disabled,
    select:disabled,
    textarea:disabled {
        opacity: 0.5;
        color: GrayText !important;
        border-color: GrayText !important;
    }
}