/* =========================
   VARIABLES (SISTEMA BASE)
========================= */

:root {
    --bg: #ffffff;
    --panel: #ffffff;
    --text: #0f172a;
    --muted: #6b7280;
    --border: #eef0f2;
    --hover: #f6f7f9;
    /* Variables para elementos destacados/nuevos */
    --accent-bg: #e7f3ff;
    --accent-text: #004085;
}

.icon-card-stats {
    border: 1px solid var(--border);
    color: var( --muted);
}


/* 2. Sobrescribir valores para Modo Oscuro */

body.dark-mode {
    --bg: #0f172a;
    /* Fondo general oscuro */
    --panel: #1e293b;
    /* Fondo de tarjetas y sidebar */
    --text: #303030;
    /* Texto casi blanco */
    --muted: #94a3b8;
    /* Texto secundario gris claro */
    --border: #334155;
    /* Bordes sutiles oscuros */
    --hover: #1e293b;
    /* Color de resalte */
    /* Variables para elementos destacados/nuevos */
    --accent-bg: #1e3a8a;
    /* Un azul más profundo */
    --accent-text: #bfdbfe;
    /* Un azul muy claro para contraste */
}


/* =========================
   BASE
========================= */

html,
body {
    max-width: 100%;
    overflow-x: hidden;
}

body {
    font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 0;
    line-height: 1.5;
    font-weight: 400;
    -webkit-font-smoothing: antialiased;
}

body.dark-mode {
    background: #1a202c;
    color: white;
}

body.dark-mode .card {
    background: #2d3748;
    border-color: #4a5568;
}

@import url('https://fonts.googleapis.com/css2?family=Google+Sans:ital,opsz,wght@0,17..18,400..700;1,17..18,400..700&family=Outfit:wght@100..900&display=swap');

/* =========================
   CONTAINER SYSTEM
========================= */

.container {
    width: 100%;
    margin: 0 auto;
    padding: 0 16px;
}

.container-sm {
    max-width: 640px;
}

.container-md {
    max-width: 768px;
}

.container-lg {
    max-width: 1024px;
}

.container-xl {
    max-width: 1280px;
}

.container-xxl {
    max-width: 1536px;
}


/* =========================
   GRID FLEX SYSTEM
========================= */

.row {
    display: flex;
    flex-wrap: wrap;
    margin-left: -8px;
    margin-right: -8px;
}

.col {
    flex: 1 0 0%;
    padding-left: 8px;
    padding-right: 8px;
}

.col-1 {
    flex: 0 0 8.333%;
}

.col-2 {
    flex: 0 0 16.666%;
}

.col-3 {
    flex: 0 0 25%;
}

.col-4 {
    flex: 0 0 33.333%;
}

.col-6 {
    flex: 0 0 calc(50% - 16px);
    max-width: calc(50% - 16px);
}

.col-12 {
    flex: 0 0 100%;
    max-width: 100%;
}


/* =========================
   DISPLAY HELPERS
========================= */

.d-block {
    display: block;
}

.d-inline {
    display: inline;
}

.d-inline-block {
    display: inline-block;
}

.d-flex {
    display: flex;
}

.d-none {
    display: none;
}


/* =========================
   FLEX UTILITIES
========================= */

.flex-row {
    flex-direction: row;
}

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

.justify-start {
    justify-content: flex-start;
}

.justify-end {
    justify-content: flex-end;
}

.justify-center {
    justify-content: center;
}

.justify-between {
    justify-content: space-between;
}

.justify-around {
    justify-content: space-around;
}

.align-start {
    align-items: flex-start;
}

.align-center {
    align-items: center;
}

.align-end {
    align-items: flex-end;
}

.flex-wrap {
    flex-wrap: wrap;
}

.flex-nowrap {
    flex-wrap: nowrap;
}

.gap-1 {
    gap: 4px;
}

.gap-2 {
    gap: 8px;
}

.gap-3 {
    gap: 12px;
}

.gap-4 {
    gap: 16px;
}

.gap-5 {
    gap: 24px;
}


/* =========================
   SPACING SYSTEM
========================= */

.m-0 {
    margin: 0;
}

.m-1 {
    margin: 4px;
}

.m-2 {
    margin: 8px;
}

.m-3 {
    margin: 12px;
}

.m-4 {
    margin: 16px;
}

.m-5 {
    margin: 24px;
}

.mt-1 {
    margin-top: 4px;
}

.mt-2 {
    margin-top: 8px;
}

.mt-3 {
    margin-top: 12px;
}

.mt-4 {
    margin-top: 16px;
}

.mt-5 {
    margin-top: 24px;
}

.mb-1 {
    margin-bottom: 4px;
}

.mb-2 {
    margin-bottom: 8px;
}

.mb-3 {
    margin-bottom: 12px;
}

.mb-4 {
    margin-bottom: 16px;
}

.mb-5 {
    margin-bottom: 24px;
}

.p-0 {
    padding: 0;
}

.p-1 {
    padding: 4px;
}

.p-2 {
    padding: 8px;
}

.p-3 {
    padding: 12px;
}

.p-4 {
    padding: 16px;
}

.p-5 {
    padding: 24px;
}


/* =========================
   WIDTH / HEIGHT
========================= */

.w-25 {
    width: 25%;
}

.w-50 {
    width: 50%;
}

.w-75 {
    width: 75%;
}

.w-100 {
    width: 100%;
}

.h-100 {
    height: 100%;
}

.h-100vh {
    height: 100vh;
}


/* =========================
   POSITION
========================= */

.position-relative {
    position: relative;
}

.position-absolute {
    position: absolute;
}

.position-fixed {
    position: fixed;
}


/* =========================
   SIDEBAR CLEAN
========================= */

.sidebar {
    width: 260px;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    background: var(--panel);
    border-right: 1px solid var(--border);
    padding: 18px 14px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    scrollbar-width: thin;
}


/* Estilos base de la sidebar (Modo Claro) */

.sidebar {
    background-color: #ffffff;
    color: #333;
    /* tus otros estilos... */
}

.sidebar a {
    color: #444;
    text-decoration: none;
}


/* --- MODO OSCURO --- */


/* Cuando el body tiene la clase dark-mode, cambiamos la sidebar */

body.dark-mode .sidebar {
    background-color: #1e293b;
    /* Un azul muy oscuro o gris oscuro */
    color: #f1f5f9;
    border-right: 1px solid #334155;
}


/* Cambiar el color de los enlaces en modo oscuro */

body.dark-mode .sidebar a {
    color: #cbd5e1;
}


/* Cambiar el color de los textos secundarios (nombre de usuario, etiquetas "General") */

body.dark-mode .sidebar .text-muted {
    color: #94a3b8 !important;
}


/* Efecto hover en los enlaces para que resalten */

body.dark-mode .sidebar a:hover {
    background-color: #334155;
    color: #ffffff;
}


/* El badge de 'admin' o el rol */

body.dark-mode .sidebar .badge {
    background-color: #334155;
    color: #f8fafc;
}

.menu a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    margin: 2px 0;
    border-radius: 10px;
    text-decoration: none;
    color: var(--text);
    font-size: 0.92em;
    transition: background 0.15s ease;
}

.menu a i {
    width: 18px;
    text-align: center;
    opacity: 0.8;
    font-size: 0.95em;
}

.menu a:hover {
    background: var(--hover);
}

.sidebar h3 {
    font-size: 1.1rem;
    font-weight: 500;
}

.sidebar-profile-wrap {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-profile-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-profile-top-row {
    justify-content: space-between;
}

.sidebar-profile-role-row {
    justify-content: flex-start;
}

.sidebar-profile-name-link {
    font-weight: 600;
    color: inherit;
    text-decoration: none;
}

.sidebar-profile-name-link:hover {
    text-decoration: underline;
}

.sidebar-profile-role {
    margin-left: 0;
}

.sidebar-profile-edit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    text-decoration: none;
    transition: background 0.2s ease;
    padding: 4px;
}

.sidebar-profile-edit:hover {
    background-color: var(--hover);
}


/* Etiqueta de rol: color según el rol */

.sidebar-profile-role {
    text-transform: capitalize;
    font-weight: 600;
    border: none;
    color: #ffffff !important;
}

.sidebar-role-superadmin {
    background: #d8b4fe;
    color: #fff;
    border-color: #d8b4fe;
}

.sidebar-role-admin {
    background: #93c5fd;
    color: #fff;
    border-color: #93c5fd;
}

.sidebar-role-user {
    background: #a7f3d0;
    color: #fff;
    border-color: #a7f3d0;
}


/* Nombre de usuario (un punto menor que el texto base) */

.sidebar-profile-name {
    font-size: 0.9rem;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}


/* Iconos de perfil: búsqueda + ajustes pegados al margen derecho */

.sidebar-profile-icons {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-left: auto;
}

.sidebar-profile-icons .sidebar-profile-edit {
    width: 28px;
    height: 28px;
    font-size: 0.95rem;
    border-radius: 6px;
}


/* Panel de búsqueda del sidebar */

.sidebar-search-panel {
    margin-bottom: 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--panel);
    padding: 6px 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.sidebar-search-panel .mobile-search-item+.mobile-search-item {
    border-top: 1px solid var(--border);
}

.badge {
    font-size: 0.75rem;
    padding: 2px 8px;
    border: 1px solid #e5e7eb;
    border-radius: 999px;
    display: inline-block;
    color: #6b7280;
}


/* =========================
   CONTENT AREA
========================= */

.content {
    margin-left: 260px;
    padding: 10px 40px;
    width: calc(100% - 260px);
    box-sizing: border-box;
}


/* =========================
   MOBILE TOP BAR
========================= */

.mobile-top-bar {
    display: none;
}

.mobile-top-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    font-size: 1.1rem;
    text-decoration: none;
    flex-shrink: 0;
    transition: background 0.12s;
}

.mobile-top-icon:hover {
    background: var(--hover);
}

.mobile-search-item+.mobile-search-item {
    border-top: 1px solid var(--border);
}

.cal-sug-tipo {
    font-size: 0.7rem;
    padding: 2px 10px;
    border-radius: 10px;
    background: var(--hover);
    color: var(--muted);
    white-space: nowrap;
}

.cal-sug-tipo.receta {
    background: #e0f2fe;
    color: #075985;
}

.cal-sug-tipo.menu {
    background: #f3e8ff;
    color: #6b21a8;
}


/* =========================
   SIDEBAR TOGGLE (hamburguesa)
========================= */

.sidebar-toggle {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 1001;
    background: #1344ff;
    border: none;
    border-radius: 10px;
    width: 40px;
    height: 40px;
    cursor: pointer;
    font-size: 1.2rem;
    color: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    align-items: center;
    justify-content: center;
    transition: left 0.3s ease;
}

.sidebar-toggle:hover {
    background: #0f3ad4;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 998;
    background: rgba(0, 0, 0, 0.4);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.show {
    opacity: 1;
}


/* Estado abierto del sidebar en móvil */

.sidebar.open {
    transform: translateX(0) !important;
}

@media (max-width: 991px) {
    .mobile-top-bar {
        display: flex;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1001;
        height: 52px;
        align-items: center;
        gap: 8px;
        padding: 0 12px;
        background: var(--panel);
        border-bottom: 1px solid var(--border);
    }
    .mobile-top-bar-title {
        font-size: 1rem;
        font-weight: 600;
        color: var(--text);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        line-height: 1;
    }
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 280px;
        height: 100vh;
        z-index: 999;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        border-right: 1px solid var(--border);
        border-bottom: none;
    }
    .sidebar-toggle {
        display: flex;
        position: static;
        width: 36px;
        height: 36px;
        background: transparent;
        color: var(--text);
        box-shadow: none;
        border-radius: 8px;
        flex-shrink: 0;
    }
    .sidebar-toggle:hover {
        background: var(--hover);
    }
    .sidebar-overlay.show {
        display: block;
    }
    .content {
        margin-left: 0;
        width: 100%;
        padding: 20px 16px;
        padding-top: 72px;
    }
    body.dark-mode .sidebar-overlay {
        background: rgba(0, 0, 0, 0.6);
    }
    body.dark-mode .mobile-top-bar {
        background: #1e293b;
        border-bottom-color: #334155;
    }
    body.dark-mode .mobile-top-bar-title {
        color: #f1f5f9;
    }
    body.dark-mode .sidebar-toggle {
        color: #f1f5f9;
    }
    body.dark-mode .mobile-top-icon {
        color: #f1f5f9;
    }
    body.dark-mode #mobileSearchPanel {
        background: #0f172a;
    }
}

@media (max-width: 640px) {
    h1 {
        font-size: 1.4em;
    }
    .row {
        margin-left: 0;
        margin-right: 0;
    }
    .col-3,
    .col-4,
    .col-6,
    .col-12 {
        flex: 0 0 100%;
        max-width: 100%;
    }
    .d-flex.justify-between {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    /* Form controls responsive */
    select,
    input,
    textarea,
    .form-control,
    .form-select {
        font-size: 16px !important;
        max-width: 100% !important;
    }
    select {
        min-height: 38px;
    }
    /* Tablas responsive: scroll horizontal si es necesario */
    .card.p-0.overflow-auto {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }
    table {
        min-width: 0 !important;
    }
    /* Badges y elementos inline */
    .badge,
    .check-label {
        font-size: 0.75rem !important;
    }
}


/* =========================
   TYPOGRAPHY
========================= */

h1,
h2,
h3 {
    font-weight: 500;
    margin-bottom: 12px;
}

p {
    color: var(--muted);
    font-size: 0.95em;
}


/* =========================
   CARD SYSTEM
========================= */

.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
}


/* =========================
   TABLES CLEAN
========================= */

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    font-size: 0.8em;
    font-weight: 500;
    color: var(--muted);
    padding: 10px;
    border-bottom: 1px solid var(--border);
}

td {
    padding: 10px;
    font-size: 0.92em;
    border-bottom: 1px solid #f3f4f6;
}

tr:hover {
    background: var(--hover);
}


/* =========================
   BUTTON SYSTEM
========================= */

button,
.btn,
a.btn {
    border-radius: 4px;
    padding: 10px 22px;
    border: 1px solid var(--border);
    background: #f3f4f6;
    cursor: pointer;
    font-weight: 400;
    font-size: 0.92em;
    color: var(--text);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    line-height: 1em;
}

.btn-icon {
    width: 40px;
    min-width: 40px;
    height: 40px;
    padding: 0;
    justify-content: center;
    border-radius: 5px;
}

.btn-icon i {
    margin: 0;
    width: auto;
    height: auto;
}

button:hover,
.btn:hover {
    background: var(--hover);
}

body.dark-mode button:hover,
body.dark-mode .btn:hover,
body.dark-mode a.btn:hover {
    color: white
}


/* =========================
   FORMS
========================= */

input,
select,
textarea {
    box-sizing: border-box;
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 0.92em;
    background: #fff;
    margin-bottom: 10px;
}

textarea {
    min-height: 150px;
    max-width: 100%;
    resize: vertical;
    overflow: auto;
    word-wrap: break-word;
}

input:focus,
textarea:focus {
    outline: none;
    border-color: #d1d5db;
}

.btn-cocinar {
    transition: background 0.15s, box-shadow 0.15s, transform 0.15s;
}

.btn-cocinar:hover {
    background: #000 !important;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.25);
    transform: translateY(-1px);
}

.form-tip {
    display: inline-flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 10px 14px;
    border-radius: 12px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e40af;
    font-size: 0.92em;
    line-height: 1.4;
    margin-top: 0.5rem;
    margin-bottom: 0.75rem;
}

.form-tip i {
    min-width: 1.25rem;
    font-size: 1rem;
    color: #2563eb;
    margin-top: 0.1rem;
}

.form-tip span {
    display: block;
    color: #1e3a8a;
}

.form-tip.tip-red {
    background: #fef2f2;
    border-color: #fecaca;
    color: #991b1b;
}

.form-tip.tip-red i {
    color: #dc2626;
}

.form-tip.tip-blue {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #1e3a8a;
}

.form-tip.tip-blue i {
    color: #2563eb;
}

.form-tip.tip-green {
    background: #ecfdf5;
    border-color: #bbf7d0;
    color: #166534;
}

.form-tip.tip-green i {
    color: #16a34a;
}

.form-tip.tip-yellow {
    background: #fefce8;
    border-color: #fef08a;
    color: #92400e;
}

.form-tip.tip-yellow i {
    color: #d97706;
}

.form-tip.tip-orange {
    background: #fff7ed;
    border-color: #fed7aa;
    color: #c2410c;
}

.form-tip.tip-orange i {
    color: #ea580c;
}

.field-info-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.field-info-trigger,
.field-info-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #b7b7b7;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
    padding: 0;
}

.field-info-trigger:hover,
.field-info-btn:hover {
    color: #282828;
    transform: translateY(-1px);
}

.field-info-text {
    display: block;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    background: #f8fafc;
    border: 1px solid #dbeafe;
    color: #475569;
    font-size: 0.9rem;
    line-height: 1.5;
    margin-top: 0.5rem;
}

.collapsible-note {
    border: 1px solid #d1d5db;
    border-radius: 12px;
    background: #f8fafc;
    padding: 1rem;
    margin-top: 0.75rem;
}

.toggle-note-btn {
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.5rem 0.9rem;
    font-size: 0.86rem;
    color: var(--text);
    background: #fff;
}

.toggle-note-btn:hover {
    background: var(--hover);
}

.field-info-trigger-custom {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
    font-size: 1.1em;
    margin-left: 0.5rem;
    padding: 0;
}

.field-info-trigger-custom:hover {
    color: #a1a1aa;
}

.field-info-trigger-custom i {
    color: inherit;
}

.field-info-text-custom {
    background: #f5ffe8;
    border-color: #93e614;
    color: #1f2937;
}

.relationship-section-icon {
    font-size: 1.1rem;
    color: #6b7280;
    margin-right: 0.75rem;
    margin-top: 10px;
}

.btn-remove-row {
    min-width: 46px;
    min-height: 42px;
    padding: 0 0.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-remove-row i {
    font-size: 1rem;
}


/* =========================
   LOGIN
========================= */

.login-container {
    max-width: 360px;
    margin: 80px auto;
    padding: 28px;
    border: 1px solid var(--border);
    border-radius: 14px;
}


/* =========================
   UTILITIES
========================= */

a {
    text-decoration: none;
}

.error {
    color: #ef4444;
}

.success {
    color: #22c55e;
}

.logo-icon {
    display: inline-block;
    background-image: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 69.17 74.38'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bstroke-linecap:round;stroke-linejoin:round%7D.cls-1,.cls-2%7Bfill:none;stroke:%231044ff;stroke-width:7.6px%7D.cls-2%7Bstroke-linejoin:bevel%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M64.71,3.8l-24.52,32.12c-2.15,2.81-6.39,2.81-8.54,0l-7.84-10.26'/%3E%3Cpath class='cls-2' d='M59.48,11.63l5.89,46.76c0,6.74-5.46,12.2-12.2,12.2H16c-6.74,0-12.2-5.46-12.2-12.2l4.93-37.18c0-6.74,5.46-12.2,12.2-12.2h24.56'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    margin-bottom: -6px;
    margin-right: 0px;
}

.login-container {
    text-align: center
}

.logo-title {
    font-family: "Google Sans", sans-serif;
    position: relative;
    display: inline-block;
    padding-right: 5rem;
    margin-top: 0px;
}

.logo-title::before {
    content: attr(data-version);
    display: block;
    position: absolute;
    right: 0;
    bottom: 0.5rem;
    padding: 2px 8px;
    background: #f3f4f6;
    color: var(--text);
    border-radius: 999px;
    font-size: 0.75rem;
    line-height: 1;
    white-space: nowrap;
}

h3.logo-title {
    font-size: 22px;
}

.login-container .logo-title {
    width: 100%;
    text-align: center;
}

.sidebar .logo-icon,
.logo-icon {
    width: 28px;
    height: 30px;
    background-image: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 69.17 74.38'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bstroke-linecap:round;stroke-linejoin:round%7D.cls-1,.cls-2%7Bfill:none;stroke:%231044ff;stroke-width:7.6px%7D.cls-2%7Bstroke-linejoin:bevel%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M64.71,3.8l-24.52,32.12c-2.15,2.81-6.39,2.81-8.54,0l-7.84-10.26'/%3E%3Cpath class='cls-2' d='M59.48,11.63l5.89,46.76c0,6.74-5.46,12.2-12.2,12.2H16c-6.74,0-12.2-5.46-12.2-12.2l4.93-37.18c0-6.74,5.46-12.2,12.2-12.2h24.56'/%3E%3C/svg%3E");
    margin-left: -3px;
}

body.dark-mode input,
body.dark-mode select,
body.dark-mode textarea {
    background: #262d3a;
    border: 1px solid #45525f;
    color: #c2c2c2;
}

#mapa-sigpac {
    cursor: crosshair !important;
    /* Cambia el cursor para indicar que puedes marcar */
}


/* =========================================================
   FULLSCREEN MAPA
========================================================= */

#btnFullscreenMapa {
    position: relative;
    z-index: 100001;
}

#contenedor-mapa.fullscreen #btnFullscreenMapa {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 100001;
    background: #212529;
    color: #fff;
    border-color: #212529;
}

#contenedor-mapa.fullscreen #mapa-dibujo {
    height: calc(100vh - 30px) !important;
}

#contenedor-mapa.fullscreen .leaflet-control-container {
    z-index: 100000;
}

.layout-distribuido {
    display: grid;
    grid-template-columns: 1fr 450px;
    gap: 20px;
    height: calc(100vh - 120px);
    min-height: 550px;
}

#contenedor-mapa-izq {
    position: relative;
    height: 100%;
    border: 2px solid #3498db;
    border-radius: 8px;
    overflow: hidden;
    background: #eee;
    /* CORRECCIÓN: Forzamos a que el mapa cree su propio contexto de apilamiento bajo */
    z-index: 1;
}

#mapa-dibujo {
    width: 100%;
    height: 100%;
    /* CORRECCIÓN ADICIONAL: Evita que capas internas de Leaflet escalen por encima */
    z-index: 1;
}

.panel-formulario-der {
    height: 100%;
    overflow-y: auto;
    padding-right: 5px;
    max-width: 100%;
    overflow-x: hidden;
}


/* Si tu sidebar sigue quedando por debajo, puedes descomentar estas líneas 
  para asegurar que el contenedor global de tu app web mande los menús al frente:
*/


/* Asegura que el contenido del formulario se mantenga en su propio nivel inferior al sidebar */

.content-fluid {
    position: relative;
    z-index: 1;
}


/* Fuerza a que el menú lateral y la cabecera (clases habituales en plantillas de administración) queden siempre por encima */

.sidebar,
#sidebar,
.main-sidebar,
.navbar,
.header {
    z-index: 1050 !important;
}


/* CORRECCIÓN DE DISTRIBUCIÓN: Desplazamos el contenido para que no se meta bajo el sidebar */

.seccion-recinto-container {
    padding-left: 326px;
    /* Ajusta este valor si tu sidebar es más ancho o estrecho (ej: 250px o 280px) */
    position: relative;
    z-index: 1;
}

.layout-distribuido {
    display: grid;
    grid-template-columns: 1fr 450px;
    gap: 20px;
    height: calc(100vh - 140px);
    min-height: 550px;
}

#contenedor-mapa-izq {
    position: relative;
    height: 100%;
    border: 2px solid #3498db;
    border-radius: 8px;
    overflow: hidden;
    background: #eee;
}

#mapa-dibujo {
    width: 100%;
    height: 100%;
    z-index: 1;
}

.panel-formulario-der {
    height: 100%;
    overflow-y: auto;
    padding-right: 5px;
    position: relative;
}

.weather-container-form {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 20px;
    display: none;
}

.weather-container-form.active {
    display: block;
}

.weather-title-section {
    font-size: 11px;
    font-weight: 700;
    color: #000000;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
    border-bottom: 2px solid #2ecc71;
    padding-bottom: 2px;
}

.weather-main {
    display: flex;
    align-items: center;
    gap: 12px;
}

.weather-temp {
    font-size: 24px;
    font-weight: 800;
    color: #000000;
}

.weather-icon {
    font-size: 28px;
}

.weather-details {
    font-size: 12px;
    color: #000000;
    font-weight: 500;
    margin-top: 4px;
    margin-bottom: 12px;
}

.forecast-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 0;
    border-bottom: 1px solid #e9ecef;
    color: #000000;
    font-size: 12px;
}

.forecast-row:last-child {
    border-bottom: none;
}

.forecast-day {
    font-weight: 700;
    color: #000000;
    min-width: 55px;
}

.forecast-temps {
    font-weight: 700;
    color: #000000;
}

.forecast-min {
    color: #0984e3;
}

.forecast-wind {
    font-size: 11px;
    color: #4b5320;
    font-weight: 600;
    min-width: 65px;
    text-align: right;
}


/* PANTALLA DE CARGA (SPINNER) */

.wms-loader {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.85);
    z-index: 99;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-radius: .375rem;
    transition: opacity 0.2s ease;
}

.wms-loader .spinner-border {
    width: 3rem;
    height: 3rem;
    color: #3498db;
}

.d-none {
    display: none !important;
}

.modal-backdrop-custom {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content-custom {
    background-color: var(--bg);
    border-radius: 8px;
    width: 600px;
    max-width: 90%;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
}

.modal-header-custom {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-body-custom {
    padding: 20px;
    max-height: 70vh;
    overflow-y: auto;
}

.modal-footer-custom {
    padding: 15px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.grid-modal {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.tooltip-marker {
    position: relative;
    display: inline-block;
    cursor: help;
}

.tooltip-marker::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 50%;
    top: calc(100% + 8px);
    transform: translateX(-50%);
    min-width: 140px;
    max-width: 260px;
    white-space: pre-wrap;
    padding: 0.45rem 0.65rem;
    background: rgba(15, 23, 42, 0.95);
    color: #fff;
    font-size: 0.78rem;
    line-height: 1.3;
    border-radius: 0.35rem;
    opacity: 0;
    pointer-events: none;
    z-index: 999;
    transition: opacity 0.12s ease;
    text-align: center;
}

.tooltip-marker::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 100%;
    transform: translateX(-50%);
    border-width: 6px;
    border-style: solid;
    border-color: rgba(15, 23, 42, 0.95) transparent transparent transparent;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.12s ease;
}

.tooltip-marker:hover::after,
.tooltip-marker:hover::before,
.tooltip-marker.show::after,
.tooltip-marker.show::before {
    opacity: 1;
}

.d-none {
    display: none !important;
}


/* =========================
   FORM RECETAS - COLLAPSIBLE SECTIONS (MÓVIL)
========================= */

@media (max-width: 768px) {
    .section-collapsible .section-header {
        cursor: pointer;
        user-select: none;
        -webkit-tap-highlight-color: transparent;
    }
    .section-collapsible .section-header:active {
        background: var(--hover);
        border-radius: 6px;
    }
    .section-collapsible .section-body {
        transition: none;
    }
    .section-collapsible .section-chevron {
        transition: transform 0.2s ease;
    }
}

.section-collapsible .section-body {
    padding-top: 10px;
}


/* =========================
   GALERÍA - ESTRELLA DESTACADO
========================= */

.gal-star-btn {
    padding: 0 !important;
    width: 22px !important;
    height: 22px !important;
    margin: -3px !important;
}

.gal-star-btn i {
    pointer-events: none;
}


/* =========================
   FORM RECETAS - OVERFLOW FIX (MÓVIL)
========================= */

.form-dos-col {
    max-width: 100%;
    overflow: hidden;
}

@media (max-width: 768px) {
    .form-dos-col {
        max-width: 100% !important;
        overflow: hidden !important;
        gap: 0.75rem !important;
    }
    .form-dos-col>.col {
        max-width: 100%;
        overflow: hidden;
    }
    .form-dos-col .card {
        max-width: 100%;
    }
    .form-dos-col .card.section-collapsible {
        overflow: visible !important;
    }
}


/* =========================
   PASOS - DRAGGING
========================= */

.paso-item.dragging {
    opacity: 0.4;
    border-color: #f59e0b;
}


/* =========================
   BOTONES FIXED BOTTOM (MÓVIL)
========================= */

@media (max-width: 768px) {
    .form-actions-fixed {
        position: fixed !important;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 9999;
        background: var(--panel);
        border-top: 1px solid var(--border);
        padding: 10px 16px;
        margin: 0 !important;
        justify-content: center;
        box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.08);
    }
    .form-actions-fixed .btn {
        font-size: 0.85rem;
        padding: 8px 18px;
    }
    body.dark-mode .form-actions-fixed {
        background: #1e293b;
        border-top-color: #334155;
    }
    /* Añadir padding inferior al contenido para no tapar botones */
    .content {
        padding-bottom: 80px !important;
    }
}


/* =========================
   TOP ACTIONS FIXED (MÓVIL)
========================= */

@media (max-width: 768px) {
    .form-top-actions {
        position: fixed !important;
        top: 52px;
        left: 0;
        right: 0;
        z-index: 500;
        background: var(--panel);
        padding: 8px 16px;
        margin: 0 !important;
        border-bottom: 1px solid var(--border);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    }
    body.dark-mode .form-top-actions {
        background: #1e293b;
        border-bottom-color: #334155;
    }
    .form-top-actions .btn {
        font-size: 0.85rem;
    }
    /* Espacio extra para el contenido debajo del top bar fixed (solo si existe .form-top-actions) */
    .content:has(.form-top-actions) {
        padding-top: 120px !important;
    }
}


/* =========================
   PAPELERA DRAG & DROP (GALERÍA) - mismo diseño que calendario
========================= */

#galTrashBin {
    position: fixed;
    bottom: 80px;
    right: 24px;
    z-index: 9998;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.9);
    color: #fff;
    font-size: 0.75rem;
    gap: 4px;
    transform: scale(0.6);
    opacity: 0;
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
    box-shadow: 0 4px 20px rgba(239, 68, 68, 0.4);
}

#galTrashBin.visible {
    transform: scale(1);
    opacity: 1;
    pointer-events: all;
}

#galTrashBin i {
    font-size: 1.8rem;
}

#galTrashBin span {
    font-size: 0.6rem;
    text-align: center;
    line-height: 1.2;
}

.gal-img-wrap {
    cursor: grab;
}

.gal-img-wrap:active {
    cursor: grabbing;
}

@media (max-width: 768px) {
    #galTrashBin {
        bottom: 100px;
        right: 16px;
        width: 80px;
        height: 80px;
    }
}


/* =========================
   TOAST DESHACER (GALERÍA) - mismo diseño que calendario
========================= */

#galToast {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(-150px);
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 16px;
    background: #1344ff;
    color: #fff;
    padding: 12px 20px;
    border-radius: 12px;
    font-size: 0.9rem;
    box-shadow: 0 4px 20px rgba(19, 68, 255, 0.3);
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
}

#galToast.visible {
    transform: translateX(-50%) translateY(0);
    pointer-events: all;
}

#galToast #galToastMsg {
    flex: 1;
    white-space: nowrap;
}

#galToast #galToastUndo {
    background: #f59e0b;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 6px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}

#galToast #galToastUndo:hover {
    background: #d97706;
}

@media (max-width: 768px) {
    #galToast {
        top: 70px;
        padding: 10px 16px;
        font-size: 0.85rem;
        max-width: 90%;
    }
    #galToast #galToastUndo {
        padding: 5px 12px;
        font-size: 0.8rem;
    }
}


/* =========================
   PASO INPUT → TEXTAREA EXPANDIBLE
========================= */

.paso-input[data-expanded] {
    display: none;
}

textarea.paso-input {
    min-height: 80px;
    resize: vertical;
    font-size: 0.85rem;
}


/* Botón solo icono (eliminar) */

.btn-icon-only {
    width: 38px;
    min-width: 38px;
    height: 38px;
    padding: 0 !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-icon-only i {
    margin: 0;
}