﻿:root {
    --bg: #f4f7fb;
    --card: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --line: #e5e7eb;
    --primary: #2f6fed;
    --primary-soft: #eaf1ff;
    --success: #0f9d58;
    --success-soft: #e8f8ef;
    --danger: #dc2626;
    --danger-soft: #fee2e2;
    --sidebar: #183c7a;
    --sidebar-soft: #2752a0;
    --sidebar-text: #f8fbff;
    --shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
    --radius: 18px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Inter, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

input,
select,
button {
    font-size: 15px;
}

input,
select {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px 14px;
    background: white;
}

    input:focus,
    select:focus {
        outline: 2px solid var(--primary-soft);
        border-color: var(--primary);
    }

.hidden {
    display: none;
}

.mensaje {
    color: var(--danger);
    font-weight: 600;
}

.tabla-vacia {
    text-align: center;
    color: var(--muted);
    padding: 18px;
}

/* =========================
   LAYOUT GENERAL
========================= */
.app {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 250px 1fr;
}

.sidebar {
    background: linear-gradient(180deg, var(--sidebar), var(--sidebar-soft));
    color: var(--sidebar-text);
    padding: 28px 20px;
}

.brand h1 {
    margin: 0 0 6px;
    font-size: 28px;
}

.brand p {
    margin: 0 0 24px;
    opacity: 0.8;
}

.menu {
    display: grid;
    gap: 12px;
}

.menu-btn {
    padding: 14px 16px;
    border: none;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--sidebar-text);
    text-align: left;
    font-size: 15px;
    cursor: pointer;
}

    .menu-btn.active {
        background: rgba(255, 255, 255, 0.18);
        font-weight: 700;
    }

    .menu-btn:disabled {
        cursor: not-allowed;
        opacity: 0.65;
    }

.main {
    padding: 26px;
    display: grid;
    gap: 22px;
}

.panel {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px;
}

.panel-header h2,
.panel-header h3 {
    margin: 0 0 6px;
}

.panel-header p {
    margin: 0;
    color: var(--muted);
}

.panel-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

/* =========================
   BOTONES GENERALES
========================= */
.btn-outline {
    border: 1px solid var(--primary);
    background: white;
    color: var(--primary);
    padding: 12px 14px;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
}

.btn-success {
    border: none;
    border-radius: 12px;
    background: var(--success);
    color: white;
    padding: 12px 14px;
    font-weight: 700;
    cursor: pointer;
}

/* =========================
   BUSQUEDA
========================= */
.search-layout {
    margin-top: 18px;
    display: grid;
    gap: 16px;
}

.search-row {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
}

.search-block {
    display: grid;
    gap: 8px;
}

    .search-block label {
        font-size: 14px;
        color: var(--muted);
        font-weight: 600;
    }

.segmented {
    display: inline-flex;
    background: #f2f4f7;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 4px;
    gap: 4px;
}

.seg-btn {
    border: none;
    background: transparent;
    color: var(--muted);
    border-radius: 999px;
    padding: 10px 18px;
    font-weight: 700;
    cursor: pointer;
}

    .seg-btn.active {
        background: white;
        color: var(--primary);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    }

.limit-block input {
    width: 90px;
}

.search-bar-wrap {
    display: grid;
    grid-template-columns: 1fr 130px;
    gap: 12px;
}

.search-input {
    border-radius: 999px;
    padding-left: 18px;
}

.search-btn {
    border: none;
    border-radius: 999px;
    background: var(--primary);
    color: white;
    font-weight: 700;
    cursor: pointer;
}

/* =========================
   GRID PRINCIPAL
========================= */
.content-grid {
    display: grid;
    grid-template-columns: 1.25fr 1fr;
    gap: 22px;
}

/* =========================
   TABLAS GENERALES
========================= */
.table-wrapper {
    overflow-x: auto;
    margin-top: 16px;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

thead {
    background: #f8fafc;
}

th,
td {
    text-align: left;
    padding: 13px 12px;
    border-bottom: 1px solid var(--line);
    font-size: 14px;
    vertical-align: middle;
}

.results-table tbody tr:hover,
.meal-table tbody tr:hover,
.analysis-table tbody tr:hover {
    background: #fafcff;
}

.select-btn {
    border: none;
    background: var(--primary-soft);
    color: var(--primary);
    padding: 8px 12px;
    border-radius: 10px;
    font-weight: 700;
    cursor: pointer;
}

.remove-btn {
    border: none;
    background: var(--danger-soft);
    color: var(--danger);
    padding: 8px 12px;
    border-radius: 10px;
    font-weight: 700;
    cursor: pointer;
}

/* =========================
   PANEL DE SELECCIÓN
========================= */
.empty-box {
    margin-top: 18px;
    padding: 20px;
    border: 1px dashed var(--line);
    border-radius: 16px;
    color: var(--muted);
    background: #fafafa;
}

.selected-panel {
    margin-top: 18px;
    display: grid;
    gap: 16px;
}

.selected-card {
    padding: 18px;
    border-radius: 16px;
    background: var(--primary-soft);
}

    .selected-card h4 {
        margin: 10px 0 8px;
    }

    .selected-card p {
        margin: 4px 0;
    }

.badge {
    display: inline-block;
    padding: 6px 10px;
    background: white;
    border-radius: 999px;
    color: var(--primary);
    font-size: 12px;
    font-weight: 700;
}

/* =========================
   FORMULARIOS
========================= */
.selected-form {
    display: grid;
    gap: 14px;
    align-items: end;
}

.field {
    display: grid;
    gap: 8px;
    min-width: 0;
}

    .field label {
        font-size: 14px;
        color: var(--muted);
        font-weight: 600;
    }

.field-button {
    align-self: end;
}

.field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 52px;
    line-height: 1.2;
    padding: 0 4px;
}

    .checkbox-label input[type="checkbox"] {
        width: auto;
        margin: 0;
        flex: 0 0 auto;
    }

/* consumo_actual */
.selected-form-4 {
    grid-template-columns: minmax(140px, 1fr) minmax(140px, 1fr) minmax(160px, 1fr) 180px;
}

    .selected-form-4 input,
    .selected-form-4 select,
    .selected-form-4 button {
        width: 100%;
        min-width: 0;
    }

/* plan_alimenticio */
.selected-form-plan {
    grid-template-columns: minmax(140px, 1fr) minmax(140px, 1fr) minmax(180px, 1fr) minmax(140px, 1fr) 220px;
}

    .selected-form-plan input,
    .selected-form-plan select,
    .selected-form-plan button {
        width: 100%;
        min-width: 0;
    }

/* =========================
   SECCIONES DE COMIDA
========================= */
.meal-grid {
    margin-top: 18px;
    display: grid;
    gap: 18px;
}

.meal-card {
    border: 1px solid var(--line);
    border-radius: 18px;
    overflow: hidden;
    background: #fcfdff;
}

.meal-header {
    padding: 14px 16px;
    background: #f8fafc;
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.meal-title-input {
    border: none;
    background: transparent;
    font-size: 18px;
    font-weight: 700;
    width: 100%;
    color: var(--text);
}

    .meal-title-input:focus {
        outline: none;
        background: white;
        border-radius: 10px;
        padding: 8px 10px;
    }

.remove-section-btn {
    border: none;
    background: #eef2ff;
    color: #4338ca;
    padding: 8px 12px;
    border-radius: 10px;
    font-weight: 700;
    cursor: pointer;
}

/* =========================
   ANÁLISIS QUÍMICO
========================= */
.analysis-controls {
    margin-top: 18px;
    display: grid;
    gap: 12px;
}

.nutrient-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.nutrient-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #f8fafc;
    font-size: 14px;
    cursor: pointer;
}

    .nutrient-chip input {
        width: auto;
        margin: 0;
    }

.analysis-sections {
    margin-top: 18px;
    display: grid;
    gap: 18px;
}

.analysis-card {
    border: 1px solid var(--line);
    border-radius: 18px;
    overflow: hidden;
    background: #fcfdff;
}

.analysis-header {
    padding: 14px 16px;
    background: #f8fafc;
    border-bottom: 1px solid var(--line);
}

    .analysis-header h3 {
        margin: 0;
    }

.analysis-empty {
    padding: 18px;
    color: var(--muted);
}

.analysis-table th,
.analysis-table td {
    white-space: nowrap;
}

.total-row {
    background: #eef4ff;
}

    .total-row td {
        font-weight: 700;
        border-top: 2px solid #dbe7ff;
    }

/* =========================
   LANDING / HOME
========================= */
.landing-body {
    min-height: 100vh;
    background: radial-gradient(circle at top left, rgba(47, 111, 237, 0.12), transparent 30%), radial-gradient(circle at bottom right, rgba(15, 157, 88, 0.10), transparent 30%), var(--bg);
}

.landing {
    max-width: 1250px;
    margin: 0 auto;
    padding: 40px 24px 60px;
    display: grid;
    gap: 26px;
}

.hero-card {
    display: grid;
    grid-template-columns: 1.2fr 0.9fr;
    gap: 26px;
    background: var(--card);
    border-radius: 28px;
    box-shadow: var(--shadow);
    padding: 34px;
    min-height: 500px;
}

.hero-content {
    display: grid;
    align-content: center;
    gap: 18px;
}

.hero-badge,
.dashboard-badge,
.visual-label {
    display: inline-flex;
    width: fit-content;
    padding: 8px 14px;
    background: var(--primary-soft);
    color: var(--primary);
    border-radius: 999px;
    font-weight: 700;
    font-size: 13px;
}

.visual-label {
    padding: 6px 10px;
    font-size: 12px;
}

.hero-title {
    margin: 0;
    font-size: 56px;
    line-height: 1;
    color: var(--text);
}

.hero-subtitle {
    margin: 0;
    font-size: 18px;
    color: var(--muted);
    max-width: 700px;
    line-height: 1.5;
}

.hero-points {
    display: grid;
    gap: 12px;
}

.hero-point {
    display: grid;
    gap: 4px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #fbfdff;
}

    .hero-point strong {
        font-size: 15px;
    }

    .hero-point span {
        color: var(--muted);
        font-size: 14px;
    }

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-top: 4px;
}

.hero-btn {
    border: none;
    border-radius: 14px;
    padding: 14px 20px;
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
}

.hero-btn-primary {
    background: var(--primary);
    color: white;
}

.hero-btn-secondary {
    background: white;
    color: var(--primary);
    border: 1px solid var(--primary);
}

.hero-visual {
    display: grid;
    align-content: center;
    gap: 18px;
}

.visual-card {
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
    border: 1px solid var(--line);
    background: white;
}

    .visual-card strong {
        display: block;
        margin: 8px 0;
        font-size: 18px;
    }

    .visual-card p {
        margin: 0;
        color: var(--muted);
        line-height: 1.45;
    }

.visual-card-2 {
    margin-left: 28px;
}

.visual-card-3 {
    margin-left: 56px;
}

.auth-area {
    display: grid;
    gap: 18px;
    margin-top: 8px;
}

.auth-panel {
    background: var(--card);
    border-radius: 24px;
    box-shadow: var(--shadow);
    padding: 26px;
    backdrop-filter: blur(6px);
    animation: fadeUp 0.35s ease;
}

.auth-panel-header h2 {
    margin: 0 0 6px;
}

.auth-panel-header p {
    margin: 0;
    color: var(--muted);
}

.auth-form {
    margin-top: 18px;
    display: grid;
    grid-template-columns: repeat(2, minmax(220px, 1fr));
    gap: 16px;
    align-items: end;
}

    .auth-form .field input {
        transition: all 0.15s ease;
        border-radius: 14px;
    }

        .auth-form .field input:focus {
            transform: translateY(-1px);
            box-shadow: 0 6px 16px rgba(47, 111, 237, 0.12);
        }

.auth-submit {
    width: fit-content;
    min-width: 180px;
    background: linear-gradient(135deg, var(--success), #13b46b);
    box-shadow: 0 6px 14px rgba(15, 157, 88, 0.25);
    transition: all 0.15s ease;
}

    .auth-submit:hover {
        transform: translateY(-1px);
        box-shadow: 0 10px 20px rgba(15, 157, 88, 0.28);
    }

.auth-message {
    margin-top: 14px;
    color: var(--danger);
    font-weight: 600;
}

    .auth-message.success {
        color: var(--success);
    }

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* =========================
   DASHBOARD
========================= */
.dashboard-body {
    min-height: 100vh;
    background: radial-gradient(circle at top left, rgba(47, 111, 237, 0.10), transparent 30%), radial-gradient(circle at bottom right, rgba(15, 157, 88, 0.08), transparent 30%), var(--bg);
}

.dashboard-page {
    max-width: 1280px;
    margin: 0 auto;
    padding: 34px 24px 60px;
    display: grid;
    gap: 24px;
}

.dashboard-hero {
    display: grid;
    grid-template-columns: 1.2fr 220px;
    gap: 18px;
    align-items: start;
    background: var(--card);
    border-radius: 28px;
    box-shadow: var(--shadow);
    padding: 30px;
}

.dashboard-hero-left {
    display: grid;
    gap: 14px;
}

.dashboard-title {
    margin: 0;
    font-size: 44px;
    line-height: 1;
    color: var(--text);
}

.dashboard-subtitle {
    margin: 0;
    color: var(--muted);
    font-size: 17px;
    line-height: 1.55;
    max-width: 760px;
}

.dashboard-tip {
    margin-top: 8px;
    padding: 14px 16px;
    border-radius: 16px;
    background: #fbfdff;
    border: 1px solid var(--line);
    color: var(--text);
}

.dashboard-hero-right {
    display: flex;
    justify-content: flex-end;
}

.dashboard-logout {
    border: 1px solid var(--danger);
    background: white;
    color: var(--danger);
    padding: 12px 16px;
    border-radius: 14px;
    font-weight: 700;
    cursor: pointer;
}

.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
}

.stat-card {
    background: var(--card);
    border-radius: 22px;
    box-shadow: var(--shadow);
    padding: 22px;
    display: grid;
    gap: 8px;
}

.stat-label {
    font-size: 13px;
    color: var(--muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.stat-value {
    font-size: 28px;
    color: var(--text);
}

.stat-text {
    margin: 0;
    color: var(--muted);
    line-height: 1.45;
}

.dashboard-main-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
}

.module-card {
    background: var(--card);
    border-radius: 24px;
    box-shadow: var(--shadow);
    padding: 26px;
    display: grid;
    gap: 14px;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

    .module-card:hover {
        transform: translateY(-3px);
        box-shadow: 0 16px 36px rgba(15, 23, 42, 0.10);
    }

.module-icon {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    font-size: 28px;
    background: var(--primary-soft);
}

.module-card h2 {
    margin: 0;
    font-size: 24px;
}

.module-card p {
    margin: 0;
    color: var(--muted);
    line-height: 1.5;
}

.module-btn {
    margin-top: 8px;
    border: none;
    border-radius: 14px;
    background: var(--primary);
    color: white;
    padding: 13px 16px;
    font-weight: 700;
    cursor: pointer;
}

    /* Botones con fruta rotatoria */
    .module-btn.fruit-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 10px;
    }

.fruit-icon {
    display: inline-block;
    transform-origin: center;
    transition: transform 0.35s ease;
}

.module-btn.fruit-btn:hover .fruit-icon {
    transform: rotate(18deg) scale(1.12);
}

/* =========================
   HEADER ACTIONS / EXCEL
========================= */
.header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.btn-excel {
    background: linear-gradient(135deg, #1d6f42, #28a745);
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    transition: all 0.2s ease;
}

    .btn-excel:hover {
        transform: translateY(-1px);
        box-shadow: 0 6px 14px rgba(0, 0, 0, 0.2);
    }

    .btn-excel:active {
        transform: translateY(0);
        box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2);
    }

/* =========================
   PACIENTES
========================= */
.patient-form {
    margin-top: 18px;
    display: grid;
    grid-template-columns: repeat(3, minmax(220px, 1fr));
    gap: 16px;
    align-items: end;
}

.patient-submit-wrap {
    display: flex;
    align-items: end;
}

.method-buttons {
    margin-top: 18px;
    display: grid;
    grid-template-columns: repeat(4, minmax(180px, 1fr));
    gap: 14px;
}

.method-btn {
    border: 1px solid var(--line);
    background: white;
    color: var(--text);
    border-radius: 16px;
    padding: 16px 18px;
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.06);
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

    .method-btn:hover {
        transform: translateY(-2px);
        box-shadow: 0 14px 28px rgba(15, 23, 42, 0.10);
        border-color: var(--primary);
    }

/* =========================
   RESPONSIVE
========================= */
@media (max-width: 1200px) {
    .selected-form-plan,
    .selected-form-4 {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 1100px) {
    .content-grid {
        grid-template-columns: 1fr;
    }

    .selected-form,
    .patient-form {
        grid-template-columns: 1fr;
    }

    .method-buttons {
        grid-template-columns: repeat(2, minmax(180px, 1fr));
    }
}

@media (max-width: 1020px) {
    .dashboard-stats,
    .dashboard-main-cards {
        grid-template-columns: 1fr;
    }

    .dashboard-hero {
        grid-template-columns: 1fr;
    }

    .dashboard-hero-right {
        justify-content: flex-start;
    }
}

@media (max-width: 980px) {
    .hero-card {
        grid-template-columns: 1fr;
    }

    .visual-card-2,
    .visual-card-3 {
        margin-left: 0;
    }

    .hero-title {
        font-size: 42px;
    }
}

@media (max-width: 860px) {
    .app {
        grid-template-columns: 1fr;
    }

    .search-bar-wrap {
        grid-template-columns: 1fr;
    }

    .panel-header-flex {
        flex-direction: column;
    }
}

@media (max-width: 760px) {
    .auth-form {
        grid-template-columns: 1fr;
    }

    .hero-actions {
        flex-direction: column;
    }

    .hero-btn {
        width: 100%;
    }
}

@media (max-width: 700px) {
    .selected-form-plan,
    .selected-form-4,
    .search-row,
    .method-buttons,
    .patient-form,
    .field-row {
        grid-template-columns: 1fr;
        flex-direction: column;
    }
}
