/**
 * AI Macro Tracker Styles
 */

/* Container */
.aimacrotracker-container {
    max-width: 900px;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* Header */
.amt-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.amt-title {
    margin: 0;
    font-size: 28px;
    color: var(--primary);
}

/* Buttons */
.amt-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.amt-btn-primary {
    background: #3b82f6;
    color: white;
}

.amt-btn-primary:hover {
    background: #2563eb;
}

.amt-btn-secondary {
    background: #e5e7eb;
    color: #374151;
}

.amt-btn-secondary:hover {
    background: #d1d5db;
}

.amt-btn-small {
    padding: 6px 12px;
    font-size: 13px;
}

.amt-refresh-btn {
    margin-top: 10px;
    width: 100%;
    justify-content: center;
}

.amt-icon {
    font-size: 16px;
}

/* Date Selector */
.amt-date-selector {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 30px;
    padding: 15px;
    background: #f9fafb;
    border-radius: 8px;
}

.amt-date-input {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    flex: 1;
}

.amt-date-nav {
    padding: 8px 12px;
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.2s;
}

.amt-date-nav:hover {
    background: #f3f4f6;
}

/* Progress Section */
.amt-progress-section {
    margin-bottom: 30px;
    padding: 20px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}

.amt-section-title {
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 18px;
    color: #1a1a1a;
}

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

.amt-progress-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.amt-progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.amt-progress-label {
    font-weight: 600;
    color: #374151;
}

.amt-progress-values {
    font-size: 14px;
    color: #6b7280;
}

.amt-progress-bar {
    height: 8px;
    background: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
}

.amt-progress-fill {
    height: 100%;
    transition: width 0.3s ease;
    border-radius: 4px;
}

.amt-progress-fill.amt-protein {
    background: linear-gradient(90deg, #ef4444, #dc2626);
}

.amt-progress-fill.amt-carbs {
    background: linear-gradient(90deg, #f59e0b, #d97706);
}

.amt-progress-fill.amt-fats {
    background: linear-gradient(90deg, #8b5cf6, #7c3aed);
}

.amt-progress-fill.amt-calories {
    background: linear-gradient(90deg, #10b981, #059669);
}

/* Input Section */
.amt-input-section {
    margin-bottom: 30px;
    padding: 20px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}

.amt-input-mode-toggle {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.amt-mode-btn {
    flex: 1;
    padding: 10px;
    background: #f9fafb;
    border: 2px solid #e5e7eb;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 500;
}

.amt-mode-btn:hover {
    background: #f3f4f6;
}

.amt-mode-btn.active {
    background: #eff6ff;
    border-color: #3b82f6;
    color: #3b82f6;
}

.amt-form-group {
    margin-bottom: 15px;
}

.amt-form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #374151;
    font-size: 14px;
}

.amt-input,
.amt-textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
}

.amt-textarea {
    resize: vertical;
}

.amt-input:focus,
.amt-textarea:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.amt-form-row {
    display: grid;
    gap: 15px;
    grid-template-columns: 1fr;
}

.amt-form-row-4 {
    grid-template-columns: repeat(4, 1fr);
}

/* Loading */
.amt-loading {
    text-align: center;
    padding: 30px;
}

.amt-spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 10px;
    border: 3px solid #e5e7eb;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: amt-spin 0.8s linear infinite;
}

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

/* Entries List */
.amt-entries-section {
    margin-bottom: 30px;
    padding: 20px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}

.amt-entries-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.amt-entry-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: #f9fafb;
    border-radius: 6px;
    transition: all 0.2s;
}

.amt-entry-item:hover {
    background: #f3f4f6;
}

.amt-entry-info {
    flex: 1;
}

.amt-entry-description {
    font-weight: 500;
    color: #1a1a1a;
    margin-bottom: 5px;
}

.amt-entry-macros {
    display: flex;
    gap: 15px;
    font-size: 13px;
    color: #6b7280;
}

.amt-entry-macro {
    display: flex;
    align-items: center;
    gap: 4px;
}

.amt-entry-expand-btn {
    background: none;
    border: none;
    color: #3b82f6;
    cursor: pointer;
    font-size: 12px;
    margin-left: 8px;
    padding: 2px 6px;
    border-radius: 3px;
    transition: all 0.2s;
}

.amt-entry-expand-btn:hover {
    background: #eff6ff;
}

.amt-entry-breakdown {
    margin-top: 10px;
    padding: 10px;
    background: #f9fafb;
    border-radius: 4px;
    border-left: 3px solid #3b82f6;
}

.amt-breakdown-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid #e5e7eb;
}

.amt-breakdown-item:last-child {
    border-bottom: none;
}

.amt-breakdown-description {
    font-weight: 500;
    color: #374151;
    font-size: 13px;
}

.amt-breakdown-macros {
    font-size: 12px;
    color: #6b7280;
}

.amt-entry-actions {
    display: flex;
    gap: 8px;
}

.amt-breakdown-open .amt-entry-actions {
    display: none;
}

.amt-entry-btn {
    padding: 6px 12px;
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.amt-entry-btn:hover {
    background: #f9fafb;
}

.amt-entry-btn.edit {
    color: #2563eb;
}

.amt-entry-btn.edit:hover {
    background: #eff6ff;
    border-color: #2563eb;
}

.amt-entry-btn.delete {
    color: #dc2626;
}

.amt-entry-btn.delete:hover {
    background: #fef2f2;
    border-color: #dc2626;
}

.amt-empty-state {
    text-align: center;
    color: #9ca3af;
    padding: 40px;
    font-style: italic;
}

/* Modal */
.amt-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.amt-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
}

.amt-modal-content {
    position: relative;
    background: white;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.amt-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e5e7eb;
}

.amt-modal-header h3 {
    margin: 0;
    font-size: 18px;
}

.amt-modal-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #9ca3af;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.amt-modal-close:hover {
    background: #f3f4f6;
    color: #1a1a1a;
}

.amt-modal-body {
    padding: 20px;
}

.amt-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 20px;
    border-top: 1px solid #e5e7eb;
}

/* Utility */
.amt-hidden {
    display: none !important;
}

/* Notice */
.aimacrotracker-notice {
    padding: 20px;
    background: #fef3c7;
    border: 1px solid #fbbf24;
    border-radius: 8px;
    text-align: center;
}

.aimacrotracker-notice a {
    color: #1a1a1a;
    font-weight: 600;
}

/* Templates */
.amt-header-buttons {
    display: flex;
    gap: 10px;
}

.amt-templates-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 15px;
    max-height: 400px;
    overflow-y: auto;
}

.amt-template-item {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 15px;
    background: #f9fafb;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
    transition: all 0.2s;
}

.amt-template-item:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
}

.amt-template-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.amt-template-icon {
    font-size: 20px;
}

.amt-template-name {
    font-weight: 600;
    color: #1a1a1a;
    font-size: 15px;
}

.amt-template-type {
    font-size: 12px;
    padding: 2px 8px;
    background: #e5e7eb;
    border-radius: 12px;
    color: #6b7280;
    text-transform: capitalize;
}

.amt-template-macros {
    display: flex;
    gap: 12px;
    font-size: 13px;
    color: #6b7280;
}

.amt-template-description {
    font-size: 12px;
    color: #9ca3af;
    font-style: italic;
    margin-bottom: 5px;
}

.amt-template-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    padding-top: 16px;
    border-top: 1px solid #e5e7eb;
}

.amt-entry-btn.save-template {
    color: #f59e0b;
}

.amt-entry-btn.save-template:hover {
    background: #fffbeb;
    border-color: #f59e0b;
}

/* Quick Template Dropdown */
.amt-quick-template-wrapper {
    position: relative;
    flex: 1;
}

.amt-quick-template-wrapper .amt-mode-btn {
    width: 100%;
}

.amt-quick-template-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    min-width: 320px;
    max-width: 400px;
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
}

.amt-quick-template-list {
    padding: 8px;
}

.amt-quick-template-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.amt-quick-template-item:hover {
    background: #f9fafb;
}

.amt-quick-template-info {
    flex: 1;
    min-width: 0;
}

.amt-quick-template-name {
    font-weight: 600;
    color: #1a1a1a;
    font-size: 14px;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.amt-quick-template-macros {
    font-size: 12px;
    color: #6b7280;
}

.amt-quick-template-empty {
    padding: 20px;
    text-align: center;
    color: #9ca3af;
    font-size: 13px;
    font-style: italic;
}

.amt-quick-template-footer {
    padding: 8px;
    border-top: 1px solid #e5e7eb;
}

.amt-quick-template-all {
    width: 100%;
    padding: 8px 12px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    color: #374151;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.amt-quick-template-all:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
}

/* Responsive */
@media (max-width: 768px) {
    .amt-form-row-4 {
        grid-template-columns: repeat(2, 1fr);
    }

    .amt-progress-grid {
        grid-template-columns: 1fr;
    }

    .amt-header {
        flex-direction: column;
        align-items: center;
        gap: 15px;
    }

    .amt-entry-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .amt-entry-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .amt-header-buttons {
        flex-direction: column;
        width: 100%;
        display: none;
    }

    .amt-template-actions {
        flex-wrap: wrap;
    }

    .amt-input-mode-toggle {
        flex-direction: column;
    }

    .amt-quick-template-dropdown {
        right: auto;
        left: 0;
        min-width: 280px;
    }

    #amt-goals-btn {
        display: none;
    }
}
