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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

/* Login Page Styles */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.login-card {
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    padding: 40px;
    max-width: 400px;
    width: 100%;
    text-align: center;
}

.logo h1 {
    font-size: 2.5rem;
    margin-bottom: 8px;
    color: #4CAF50;
}

.logo p {
    color: #666;
    margin-bottom: 32px;
}

.login-content h2 {
    margin-bottom: 16px;
    color: #333;
}

.login-content p {
    color: #666;
    margin-bottom: 32px;
}

.google-login-btn {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    background: white;
    border: 2px solid #ddd;
    border-radius: 8px;
    padding: 12px 24px;
    text-decoration: none;
    color: #333;
    font-weight: 500;
    transition: all 0.2s;
    margin-bottom: 32px;
}

.google-login-btn:hover {
    border-color: #4285F4;
    box-shadow: 0 4px 12px rgba(66, 133, 244, 0.2);
}

.features {
    display: flex;
    flex-direction: column;
    gap: 16px;
    text-align: left;
}

.feature {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #666;
}

.feature-icon {
    font-size: 1.2rem;
}

/* App Container Styles */
.app-container {
    min-height: 100vh;
    background: #f8fafc;
}

/* Navigation Styles */
.navbar {
    background: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-left .logo {
    font-size: 1.5rem;
    color: #4CAF50;
    margin: 0;
}

.user-menu {
    position: relative;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid #e2e8f0;
    transition: border-color 0.2s;
}

.user-avatar:hover {
    border-color: #4CAF50;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    min-width: 250px;
    z-index: 1000;
    display: none;
    margin-top: 8px;
}

.dropdown-menu.show {
    display: block;
}

.dropdown-header {
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.dropdown-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

.dropdown-name {
    font-weight: 600;
    color: #333;
}

.dropdown-email {
    font-size: 0.875rem;
    color: #666;
}

.dropdown-divider {
    height: 1px;
    background: #e2e8f0;
    margin: 0 16px;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    text-decoration: none;
    color: #333;
    transition: background-color 0.2s;
}

.dropdown-item:hover {
    background: #f8fafc;
}

/* Main Content Styles */
.main-content {
    padding: 32px 24px;
}

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

.welcome-section {
    text-align: center;
    margin-bottom: 40px;
}

.welcome-section h2 {
    font-size: 2rem;
    margin-bottom: 8px;
    color: #333;
}

.welcome-section p {
    color: #666;
    font-size: 1.1rem;
}

/* Food Form Styles */
.food-form-container {
    background: white;
    border-radius: 12px;
    padding: 32px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    margin-bottom: 32px;
}

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

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

.form-group textarea {
    width: 100%;
    padding: 16px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-family: inherit;
    font-size: 1rem;
    resize: vertical;
    transition: border-color 0.2s;
}

.form-group textarea:focus {
    outline: none;
    border-color: #4CAF50;
}

.submit-btn {
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 16px 32px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 120px;
    justify-content: center;
}

.submit-btn:hover:not(:disabled) {
    background: #45a049;
    transform: translateY(-1px);
}

.submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Tips Section */
.tips-section {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.tips-section h3 {
    margin-bottom: 16px;
    color: #333;
}

.tips-list {
    list-style: none;
    padding: 0;
}

.tips-list li {
    padding: 8px 0;
    color: #666;
    position: relative;
    padding-left: 24px;
}

.tips-list li::before {
    content: "•";
    color: #4CAF50;
    position: absolute;
    left: 0;
    font-weight: bold;
}

/* Toast Styles */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
}

.toast {
    background: white;
    border-radius: 8px;
    padding: 16px 20px;
    margin-bottom: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-left: 4px solid;
    max-width: 400px;
    animation: slideIn 0.3s ease-out;
}

.toast.success {
    border-left-color: #4CAF50;
}

.toast.error {
    border-left-color: #f44336;
}

.toast-message {
    margin: 0;
    color: #333;
}

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

/* Error Page Styles */
.error-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.error-card {
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    padding: 40px;
    max-width: 500px;
    width: 100%;
    text-align: center;
}

.error-icon {
    font-size: 4rem;
    margin-bottom: 24px;
}

.error-card h1 {
    margin-bottom: 16px;
    color: #333;
}

.error-message {
    color: #666;
    margin-bottom: 32px;
    font-size: 1.1rem;
}

.error-actions {
    display: flex;
    gap: 16px;
    justify-content: center;
}

.btn {
    padding: 12px 24px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: #4CAF50;
    color: white;
}

.btn-primary:hover {
    background: #45a049;
}

.btn-secondary {
    background: #e2e8f0;
    color: #333;
}

.btn-secondary:hover {
    background: #cbd5e0;
}

/* Responsive Design */
@media (max-width: 768px) {
    .navbar {
        padding: 12px 16px;
    }

    .main-content {
        padding: 20px 16px;
    }

    .food-form-container {
        padding: 20px;
    }

    .login-card {
        padding: 24px;
    }

    .error-actions {
        flex-direction: column;
    }

    .dropdown-menu {
        right: -8px;
        min-width: 200px;
    }

    .todays-macros-content {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .macro-item {
        padding: 12px;
    }

    .macro-value {
        font-size: 1.3rem;
    }

    /* Presets responsive */
    .presets-section {
        padding: 16px;
    }

    .presets-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .presets-header h3 {
        font-size: 1.1rem;
    }

    .add-preset-btn {
        align-self: stretch;
        text-align: center;
    }

    .preset-item {
        max-width: none;
        flex: 1;
        min-width: 120px;
    }

    .preset-modal-content {
        padding: 20px;
        margin: 20px;
    }

    .preset-form-actions {
        flex-direction: column;
        gap: 8px;
    }

    .preset-form-actions .btn {
        width: 100%;
    }
}

/* Today's Macros Section */
.todays-macros-section {
    background: white;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 32px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.todays-macros-section h3 {
    margin: 0 0 16px 0;
    color: #333;
    font-size: 1.2rem;
}

.todays-macros-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 16px;
}

.macro-item {
    text-align: center;
    padding: 16px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.macro-value {
    font-size: 1.5rem;
    font-weight: 600;
    color: #4CAF50;
    margin-bottom: 4px;
}

.macro-label {
    font-size: 0.9rem;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.todays-macros-loading {
    text-align: center;
    padding: 20px;
    color: #666;
}

.todays-macros-error {
    text-align: center;
    padding: 20px;
    color: #dc3545;
    background: #f8d7da;
    border-radius: 8px;
    border: 1px solid #f5c6cb;
}

.todays-macros-empty {
    text-align: center;
    padding: 20px;
    color: #666;
    font-style: italic;
}

/* Recent Entries Section */
.recent-entries-section {
    background: white;
    border-radius: 12px;
    padding: 24px;
    margin: 24px 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.recent-entries-section h3 {
    margin: 0 0 16px 0;
    color: #333;
    font-size: 1.2rem;
}

.recent-entries-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.recent-entry {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 12px;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
    align-items: center;
}

.recent-entry-time {
    color: #666;
    font-size: 0.9rem;
    white-space: nowrap;
}

.recent-entry-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.recent-entry-food {
    font-weight: 500;
    color: #333;
}

.recent-entry-macros {
    font-size: 0.85rem;
    color: #666;
}

.recent-entry-notes {
    font-size: 0.85rem;
    color: #666;
    font-style: italic;
}

.view-more-btn {
    display: inline-block;
    margin-top: 16px;
    padding: 8px 16px;
    background: #4CAF50;
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: background-color 0.2s;
}

.view-more-btn:hover {
    background: #45a049;
}

/* Last 7 Days Section */
.last-7-days-section {
    background: white;
    border-radius: 12px;
    padding: 24px;
    margin: 24px 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.last-7-days-section h3 {
    margin: 0 0 16px 0;
    color: #333;
    font-size: 1.2rem;
}

.last-7-days-table {
    width: 100%;
    border-collapse: collapse;
}

.last-7-days-table thead th {
    text-align: left;
    font-size: 0.85rem;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 8px 12px;
    border-bottom: 1px solid #e9ecef;
}

.last-7-days-table thead th:nth-child(2),
.last-7-days-table thead th:nth-child(3),
.last-7-days-table thead th:nth-child(4),
.last-7-days-table thead th:nth-child(5) {
    text-align: right;
}

.last-7-days-table tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid #f1f5f9;
}

.last-7-days-table tbody tr:hover {
    background: #f8f9fa;
}

.last-7-days-table tbody td:nth-child(2),
.last-7-days-table tbody td:nth-child(3),
.last-7-days-table tbody td:nth-child(4),
.last-7-days-table tbody td:nth-child(5) {
    text-align: right;
}

/* Row actions */
.last-7-days-table tbody td.actions-cell {
    width: 1%;
    white-space: nowrap;
    text-align: right;
}

.row-actions-wrapper {
    position: relative;
    display: inline-block;
}

.row-actions-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 4px 8px;
    color: #64748b;
    border-radius: 6px;
}

.row-actions-btn:hover {
    background: #f1f5f9;
}

.row-actions-menu {
    position: absolute;
    right: 0;
    margin-top: 6px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.08);
    min-width: 150px;
    z-index: 1000;
    display: none;
}

.row-actions-menu.show {
    display: block;
}

.row-actions-item {
    padding: 10px 12px;
    cursor: pointer;
    font-size: 0.95rem;
}

.row-actions-item:hover {
    background: #f8fafc;
}

/* Presets Section */
.presets-section {
    background: white;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 32px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.presets-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.presets-header h3 {
    margin: 0;
    color: #333;
    font-size: 1.2rem;
}

.add-preset-btn {
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.add-preset-btn:hover {
    background: #45a049;
    transform: translateY(-1px);
}

.presets-list {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    min-height: 40px;
}

.preset-item {
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 200px;
}

.preset-item:hover {
    border-color: #4CAF50;
    background: #f0f9ff;
    transform: translateY(-1px);
}

.preset-name {
    font-weight: 500;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.preset-delete {
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    opacity: 0;
}

.preset-item:hover .preset-delete {
    opacity: 1;
}

.preset-delete:hover {
    background: #dc2626;
    transform: scale(1.1);
}

.presets-empty {
    text-align: center;
    color: #666;
    font-style: italic;
    padding: 20px;
}

.presets-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: #666;
}

.presets-loading .spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #4CAF50;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 8px;
}

/* Preset Modal */
.preset-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    display: none;
}

.preset-modal.show {
    display: flex;
}

.preset-modal-content {
    background: white;
    border-radius: 12px;
    padding: 32px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.preset-modal h3 {
    margin: 0 0 24px 0;
    color: #333;
}

.preset-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.preset-form .form-group {
    margin-bottom: 0;
}

.preset-form input,
.preset-form textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-family: inherit;
    font-size: 1rem;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.preset-form input:focus,
.preset-form textarea:focus {
    outline: none;
    border-color: #4CAF50;
}

.preset-form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 8px;
}

.preset-form-actions .btn {
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.preset-form-actions .btn-primary {
    background: #4CAF50;
    color: white;
}

.preset-form-actions .btn-primary:hover {
    background: #45a049;
}

.preset-form-actions .btn-secondary {
    background: #e2e8f0;
    color: #333;
}

.preset-form-actions .btn-secondary:hover {
    background: #cbd5e0;
}

/* Gemini API Key Modal */
.gemini-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20000;
}

.gemini-modal-content {
    background: white;
    border-radius: 12px;
    padding: 32px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.gemini-modal h3 {
    margin: 0 0 16px 0;
    color: #333;
}

.gemini-modal p {
    margin: 0 0 12px 0;
    color: #666;
    line-height: 1.5;
}

.gemini-modal .info-text {
    font-size: 0.9rem;
    margin-bottom: 24px;
}

.gemini-modal .info-text a {
    color: #4CAF50;
    text-decoration: none;
    font-weight: 500;
}

.gemini-modal .info-text a:hover {
    text-decoration: underline;
}

.gemini-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.gemini-form .form-group {
    margin-bottom: 0;
}

.gemini-form input {
    width: 100%;
    padding: 12px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-family: inherit;
    font-size: 1rem;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.gemini-form input:focus {
    outline: none;
    border-color: #4CAF50;
}

.gemini-form-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 8px;
}

.gemini-form-actions .btn {
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.gemini-form-actions .btn-primary {
    background: #4CAF50;
    color: white;
}

.gemini-form-actions .btn-primary:hover:not(:disabled) {
    background: #45a049;
}

.gemini-form-actions .btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
