/* AlmarCare - Complete Styles */

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

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

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

/* Header */
.header {
    background: white;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 20px;
    flex-wrap: wrap;
    gap: 1rem;
}

.logo h1 {
    font-size: 1.5rem;
    color: #667eea;
}

.nav {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.nav-link {
    text-decoration: none;
    color: #666;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    transition: all 0.3s;
}

.nav-link:hover {
    background: #f0f0f0;
    color: #667eea;
}

.nav-link.active {
    background: #667eea;
    color: white;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.btn-logout {
    padding: 0.5rem 1rem;
    background: #f0f0f0;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
}

/* Main Content */
.main-content {
    padding: 2rem 0;
}

.page {
    display: none;
    background: white;
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    animation: fadeIn 0.3s;
}

.page.active {
    display: block;
}

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

.page-header {
    margin-bottom: 2rem;
}

.page-header h2 {
    font-size: 2rem;
    color: #333;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: #666;
    font-size: 1rem;
}

.surgery-info {
    display: flex;
    gap: 2rem;
    margin-top: 1rem;
    padding: 1rem;
    background: #f8f9ff;
    border-radius: 8px;
    flex-wrap: wrap;
}

.surgery-date, .days-remaining {
    font-size: 1rem;
    color: #667eea;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2rem;
    border-radius: 12px;
    text-align: center;
}

.stat-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.stat-label {
    font-size: 0.9rem;
    opacity: 0.9;
}

/* Nutrition Progress */
.nutrition-progress-section {
    background: #f8f9ff;
    padding: 1.5rem;
    border-radius: 12px;
    margin-bottom: 2rem;
}

.nutrition-progress-section h3 {
    margin-bottom: 1rem;
    color: #333;
}

.macro-bars {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.macro-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.macro-header {
    display: flex;
    justify-content: space-between;
    font-weight: 500;
}

.macro-bar {
    height: 30px;
    background: #e0e0e0;
    border-radius: 15px;
    overflow: hidden;
}

.macro-fill {
    height: 100%;
    border-radius: 15px;
    transition: width 0.5s ease;
}

.macro-fill.protein {
    background: linear-gradient(90deg, #f093fb 0%, #f5576c 100%);
}

.macro-fill.carbs {
    background: linear-gradient(90deg, #4facfe 0%, #00f2fe 100%);
}

.macro-fill.fats {
    background: linear-gradient(90deg, #43e97b 0%, #38f9d7 100%);
}

.macro-fill.calories {
    background: linear-gradient(90deg, #fa709a 0%, #fee140 100%);
}

/* Care Modules */
.care-modules-section {
    margin-bottom: 2rem;
}

.care-modules-section h3 {
    margin-bottom: 1rem;
    color: #333;
}

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

.module-card {
    border: 2px solid #667eea;
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
    transition: all 0.3s;
}

.module-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.3);
}

.module-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

.module-card h4 {
    color: #667eea;
    margin-bottom: 0.5rem;
}

.module-card p {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.btn-module {
    padding: 0.5rem 1rem;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
}

/* Tasks */
.timeline-section {
    margin-top: 2rem;
}

.timeline-section h3 {
    margin-bottom: 1rem;
    color: #333;
}

.tasks-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.task-card {
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    padding: 1.5rem;
    transition: all 0.3s;
}

.task-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}

.task-card.completed {
    background: #f0fdf4;
    border-color: #86efac;
}

.task-card.pending {
    background: white;
    border-color: #e0e0e0;
}

.task-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 1rem;
}

.task-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: #333;
}

.task-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
}

.task-badge.completed {
    background: #86efac;
    color: #166534;
}

.task-badge.pending {
    background: #fbbf24;
    color: #92400e;
}

.task-date {
    color: #666;
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

.task-description {
    color: #666;
    line-height: 1.6;
    margin-bottom: 1rem;
}

.btn-complete {
    padding: 0.75rem 1.5rem;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s;
}

.btn-complete:hover:not(:disabled) {
    background: #5568d3;
    transform: scale(1.05);
}

.btn-complete:disabled {
    background: #d0d0d0;
    cursor: not-allowed;
}

/* Camera & AI Analysis */
.nutrition-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.camera-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.camera-preview {
    width: 100%;
    aspect-ratio: 4/3;
    background: #f0f0f0;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.camera-placeholder {
    text-align: center;
    color: #999;
}

.camera-icon {
    font-size: 4rem;
    display: block;
    margin-bottom: 1rem;
}

#video, #capturedImage {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.camera-controls {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.btn-camera {
    flex: 1;
    padding: 1rem;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
}

.btn-camera:hover {
    background: #5568d3;
    transform: translateY(-2px);
}

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

.btn-camera.secondary:hover {
    background: #d0d0d0;
}

/* AI Analysis */
.ai-analysis-section {
    background: #f8f9ff;
    padding: 1.5rem;
    border-radius: 12px;
}

.analysis-loading {
    text-align: center;
    padding: 2rem;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #e0e0e0;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

.analysis-results h3 {
    margin-bottom: 1rem;
    color: #333;
}

.detected-foods {
    margin-bottom: 1rem;
}

.detected-foods h4 {
    margin-bottom: 0.5rem;
    color: #666;
}

.food-tag {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: #667eea;
    color: white;
    border-radius: 20px;
    margin: 0.25rem;
    font-size: 0.9rem;
}

.porcion-tag {
    display: inline-block;
    padding: 0.4rem 0.8rem;
    background: #e0e7ff;
    color: #4338ca;
    border-radius: 16px;
    margin: 0.25rem;
    font-size: 0.85rem;
    border: 1px solid #c7d2fe;
}

.macros-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.macro-card {
    background: white;
    padding: 1rem;
    border-radius: 8px;
    text-align: center;
}

.macro-card span {
    font-size: 2rem;
    display: block;
    margin-bottom: 0.5rem;
}

.macro-card strong {
    font-size: 1.5rem;
    color: #667eea;
    display: block;
}

.macro-card p {
    color: #666;
    font-size: 0.9rem;
}

.goals-comparison {
    margin-bottom: 1.5rem;
}

.goals-comparison h4 {
    margin-bottom: 1rem;
    color: #666;
}

.goal-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.goal-item span:first-child {
    min-width: 120px;
    font-weight: 500;
}

.goal-bar {
    flex: 1;
    height: 20px;
    background: #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
}

.goal-fill {
    height: 100%;
    background: #667eea;
    border-radius: 10px;
    transition: width 0.5s ease;
}

.goal-item span:last-child {
    min-width: 80px;
    text-align: right;
    font-size: 0.9rem;
    color: #666;
}

.btn-primary {
    width: 100%;
    padding: 1rem;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

/* Meals History */
.meals-history {
    background: #f8f9ff;
    padding: 1.5rem;
    border-radius: 12px;
}

.meals-history h3 {
    margin-bottom: 1rem;
    color: #333;
}

.meal-card {
    display: flex;
    gap: 1rem;
    background: white;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.meal-card img {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border-radius: 8px;
}

.meal-info {
    flex: 1;
}

.meal-info strong {
    display: block;
    margin-bottom: 0.5rem;
    color: #333;
}

.meal-info p {
    color: #666;
    font-size: 0.9rem;
}

.empty-state {
    text-align: center;
    color: #999;
    padding: 2rem;
}

/* Education Content */
.education-container {
    margin-top: 1rem;
}

.education-tabs {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    border-bottom: 2px solid #e0e0e0;
    flex-wrap: wrap;
}

.tab-btn {
    padding: 1rem 1.5rem;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-weight: 500;
    color: #666;
    transition: all 0.3s;
}

.tab-btn:hover {
    color: #667eea;
}

.tab-btn.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.content-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.content-card {
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s;
}

.content-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.1);
}

.content-card img {
    width: 100%;
    height: 180px;
    object-fit: cover;
}

.content-icon {
    font-size: 4rem;
    text-align: center;
    padding: 2rem;
    background: #f8f9ff;
}

.content-info {
    padding: 1.5rem;
}

.content-info h4 {
    color: #333;
    margin-bottom: 0.5rem;
}

.content-info p {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.category-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: #667eea;
    color: white;
    border-radius: 20px;
    font-size: 0.8rem;
    margin-bottom: 0.5rem;
}

.btn-secondary {
    padding: 0.75rem 1.5rem;
    background: #e0e0e0;
    color: #333;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s;
    margin-top: 0.5rem;
}

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

/* Messages */
.messages-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.message-card {
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    padding: 1.5rem;
    background: white;
}

.message-card.unread {
    background: #f8f9ff;
    border-color: #667eea;
}

.message-card.priority-alta {
    border-left: 4px solid #ef4444;
}

.message-card.priority-media {
    border-left: 4px solid #f59e0b;
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 1rem;
}

.message-header strong {
    color: #333;
}

.message-date {
    color: #999;
    font-size: 0.9rem;
    margin-left: 1rem;
}

.priority-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
}

.priority-badge.alta {
    background: #fee2e2;
    color: #991b1b;
}

.priority-badge.media {
    background: #fef3c7;
    color: #92400e;
}

.message-card h4 {
    color: #667eea;
    margin-bottom: 0.5rem;
}

.message-card p {
    color: #666;
    line-height: 1.6;
    margin-bottom: 1rem;
}

.attachment {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: #f0f0f0;
    border-radius: 8px;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

/* Analytics Upload */
.analytics-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.upload-section h3 {
    margin-bottom: 1rem;
    color: #333;
}

.upload-area {
    border: 3px dashed #d0d0d0;
    border-radius: 12px;
    padding: 3rem;
    text-align: center;
    transition: all 0.3s;
    cursor: pointer;
}

.upload-area:hover, .upload-area.drag-over {
    border-color: #667eea;
    background: #f8f9ff;
}

.upload-icon {
    font-size: 4rem;
    display: block;
    margin-bottom: 1rem;
}

.upload-placeholder p {
    color: #666;
    margin-bottom: 1rem;
}

.pdf-analysis {
    margin-top: 1rem;
}

.analytics-results h3 {
    margin-bottom: 1rem;
    color: #333;
}

.values-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.value-card {
    background: #f8f9ff;
    padding: 1.5rem;
    border-radius: 12px;
    text-align: center;
}

.value-label {
    display: block;
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.value-card strong {
    display: block;
    font-size: 2rem;
    color: #667eea;
    margin-bottom: 0.25rem;
}

.value-unit {
    display: block;
    color: #999;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.value-status {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
}

.value-status.normal {
    background: #d1fae5;
    color: #065f46;
}

.value-status.high {
    background: #fee2e2;
    color: #991b1b;
}

.value-status.low {
    background: #fef3c7;
    color: #92400e;
}

/* Notifications */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #16a34a;
    color: white;
    padding: 1rem 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    z-index: 1000;
    transform: translateX(400px);
    transition: transform 0.3s ease;
}

.notification.show {
    transform: translateX(0);
}

.notification.error {
    background: #dc2626;
}

/* Responsive */
@media (max-width: 768px) {
    .header .container {
        flex-direction: column;
    }
    
    .nav {
        width: 100%;
        justify-content: center;
    }
    
    .nutrition-container,
    .analytics-container {
        grid-template-columns: 1fr;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .surgery-info {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .content-grid {
        grid-template-columns: 1fr;
    }
    
    .macros-grid {
        grid-template-columns: 1fr;
    }
    
    .values-grid {
        grid-template-columns: 1fr;
    }
}


/* ==================== TOASTS ==================== */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: white;
    padding: 15px 20px;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 10000;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

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

.toast-error {
    border-left: 4px solid #f44336;
}

.toast span:first-child {
    font-size: 20px;
}

/* ==================== LOADING OVERLAY ==================== */
#loading-overlay {
    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: 9999;
}

.loading-spinner {
    background: white;
    padding: 30px 40px;
    border-radius: 15px;
    text-align: center;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

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

.loading-spinner p {
    color: #333;
    font-weight: 500;
    margin: 0;
}
