/* ============================================================
   BOTUPHARMA APP - Estilos Globales
   Manual de Marca: Pantones 2767C / 294C / 2184C
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;1,700;1,800&display=swap');

:root {
    --primary:    #13294B;
    --secondary:  #002F6C;
    --accent:     #0084D4;
    --light:      #F3F4F6;
    --white:      #FFFFFF;
    --danger:     #EF4444;
    --success:    #10B981;
    --warning:    #F59E0B;
    --text:       #1F2937;
    --text-light: #6B7280;
    --border:     #E5E7EB;
    --sidebar-w:  260px;
    --navbar-h:   64px;
}

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

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Montserrat', sans-serif;
    background: var(--light);
    color: var(--text);
    min-height: 100vh;
}

/* ---- LOGO SVG-text ---- */
.brand-logo {
    display: flex;
    flex-direction: column;
    line-height: 1;
}
.brand-logo .brand-name {
    font-weight: 800;
    font-style: italic;
    color: var(--accent);
    letter-spacing: -1px;
}
.brand-logo .brand-tagline {
    font-weight: 400;
    font-style: italic;
    color: var(--text-light);
    font-size: 0.65em;
}
.brand-logo.white .brand-name,
.brand-logo.white .brand-tagline { color: var(--white); }

/* ---- SIDEBAR ---- */
.sidebar {
    position: fixed;
    left: 0; top: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--primary);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    z-index: 100;
    transition: transform 0.3s;
}
.sidebar-header {
    padding: 24px 20px;
    padding-top: max(24px, calc(env(safe-area-inset-top, 0px) + 8px));
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-header .brand-name { font-size: 1.5rem; color: #fff; }
.sidebar-header .brand-tagline { color: rgba(255,255,255,0.6); font-size: 0.7rem; }
.sidebar-nav { padding: 16px 0; flex: 1; }
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 20px;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
}
.sidebar-nav a:hover,
.sidebar-nav a.active {
    color: #fff;
    background: rgba(255,255,255,0.1);
    border-left: 3px solid var(--accent);
}
.sidebar-nav a i { width: 20px; text-align: center; font-size: 1rem; }
.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
}
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}
.sidebar-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--accent);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; color: #fff; font-size: 0.875rem;
}
.sidebar-user-info { flex: 1; }
.sidebar-user-name { font-size: 0.8rem; font-weight: 600; color: #fff; }
.sidebar-user-role { font-size: 0.7rem; color: rgba(255,255,255,0.6); }

/* ---- MAIN CONTENT ---- */
.main-content {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
}
.topbar {
    position: sticky; top: 0;
    background: var(--white);
    border-bottom: 1px solid var(--border);
    height: var(--navbar-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-left: max(28px, env(safe-area-inset-left, 0px));
    padding-right: max(28px, env(safe-area-inset-right, 0px));
    padding-top: 0;
    padding-bottom: 0;
    z-index: 50;
}
.topbar-title { font-size: 1.125rem; font-weight: 700; color: var(--primary); }
.page-body {
    padding-top: max(28px, env(safe-area-inset-top, 0px));
    padding-right: max(28px, env(safe-area-inset-right, 0px));
    padding-bottom: max(28px, env(safe-area-inset-bottom, 0px));
    padding-left: max(28px, env(safe-area-inset-left, 0px));
}

/* ---- CARDS ---- */
.card {
    background: var(--white);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    overflow: hidden;
}
.card-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card-title { font-size: 1rem; font-weight: 700; color: var(--primary); }
.card-body { padding: 24px; }

/* ---- STATS ---- */
.stat-card {
    background: var(--white);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.stat-icon {
    width: 48px; height: 48px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}
.stat-icon.blue { background: rgba(0,132,212,0.12); color: var(--accent); }
.stat-icon.navy { background: rgba(19,41,75,0.1); color: var(--primary); }
.stat-icon.green { background: rgba(16,185,129,0.12); color: var(--success); }
.stat-icon.yellow { background: rgba(245,158,11,0.12); color: var(--warning); }
.stat-icon.red { background: rgba(239,68,68,0.12); color: var(--danger); }
.stat-value { font-size: 1.75rem; font-weight: 800; color: var(--primary); line-height: 1; }
.stat-label { font-size: 0.78rem; color: var(--text-light); margin-top: 4px; font-weight: 500; }

/* ---- ALERT CARDS ---- */
.alert-card {
    border-radius: 10px;
    padding: 16px;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 12px;
}
.alert-card.red { background: #FEF2F2; border-left: 4px solid var(--danger); }
.alert-card.yellow { background: #FFFBEB; border-left: 4px solid var(--warning); }
.alert-card.green { background: #ECFDF5; border-left: 4px solid var(--success); }
.alert-icon { font-size: 1.25rem; margin-top: 2px; }
.alert-title { font-size: 0.9rem; font-weight: 700; }
.alert-subtitle { font-size: 0.8rem; color: var(--text-light); margin-top: 2px; }

/* ---- TABLES ---- */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
thead th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 0.78rem;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--light);
    border-bottom: 1px solid var(--border);
}
tbody td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:hover { background: #F9FAFB; }
tbody tr:last-child td { border-bottom: none; }

/* ---- BUTTONS ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 18px;
    border-radius: 8px;
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    text-decoration: none;
    white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--secondary); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: #0072b8; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #DC2626; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #D97706; }
.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 2px solid var(--primary);
}
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 0.78rem; }
.btn-xs { padding: 4px 8px; font-size: 0.72rem; }
.btn-whatsapp { background: #25D366; color: #fff; }
.btn-whatsapp:hover { background: #1ebe5d; }
.btn-icon { padding: 7px; border-radius: 7px; }
.btn-ghost { background: transparent; color: var(--text-light); }
.btn-ghost:hover { background: var(--light); color: var(--text); }

/* ---- BADGES ---- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 99px;
    font-size: 0.72rem;
    font-weight: 600;
}
.badge-blue { background: rgba(0,132,212,0.12); color: var(--accent); }
.badge-navy { background: rgba(19,41,75,0.1); color: var(--primary); }
.badge-green { background: rgba(16,185,129,0.12); color: var(--success); }
.badge-red { background: rgba(239,68,68,0.12); color: var(--danger); }
.badge-yellow { background: rgba(245,158,11,0.12); color: var(--warning); }
.badge-gray { background: var(--border); color: var(--text-light); }

/* ---- FORMS ---- */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-family: 'Montserrat', sans-serif;
    font-size: 0.875rem;
    color: var(--text);
    background: var(--white);
    transition: border-color 0.2s;
    outline: none;
}
.form-control:focus { border-color: var(--accent); }
.form-control::placeholder { color: #9CA3AF; }
select.form-control { cursor: pointer; }

/* ---- GRID ---- */
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1200px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } }
/* Fondo al abrir menú móvil (tap para cerrar) */
.sidebar-backdrop {
    display: none;
}

@media (max-width: 900px) {
    .grid-3, .grid-2 { grid-template-columns: 1fr; }
    .main-content { margin-left: 0; }

    /* Sidebar oculto: no interceptar toques en el contenido */
    .sidebar {
        transform: translateX(-100%);
        pointer-events: none;
        z-index: 110;
    }
    .sidebar.open {
        transform: translateX(0);
        pointer-events: auto;
    }

    /* Topbar y botón ☰ por encima del drawer para poder cerrar */
    .topbar {
        z-index: 120;
    }
    .menu-toggle {
        position: relative;
        z-index: 121;
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(19, 41, 75, 0.42);
        z-index: 105;
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transition: opacity 0.25s ease, visibility 0.25s;
    }
    .sidebar-backdrop.is-visible {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    /* Fecha larga (ej. jueves, 9 de abril de 2026): oculta en móvil */
    .topbar-date { display: none !important; }
}

/* ---- MODALS (SweetAlert custom) ---- */
.swal2-popup { font-family: 'Montserrat', sans-serif !important; border-radius: 12px !important; }
.swal2-title { color: var(--primary) !important; font-weight: 700 !important; }
.swal2-confirm { font-family: 'Montserrat', sans-serif !important; font-weight: 600 !important; }

/* ---- HORSE CARD ---- */
.horse-card {
    background: var(--white);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    transition: transform 0.2s, box-shadow 0.2s;
}
.horse-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.12); }
.horse-card-photo {
    width: 100%;
    height: 180px;
    object-fit: cover;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    display: flex; align-items: center; justify-content: center;
    color: rgba(255,255,255,0.4);
    font-size: 3rem;
}
.horse-card-photo img { width: 100%; height: 100%; object-fit: cover; }
.horse-card-body { padding: 16px; }
.horse-card-name { font-size: 1rem; font-weight: 700; color: var(--primary); }
.horse-card-detail { font-size: 0.78rem; color: var(--text-light); margin-top: 4px; }

/* ---- PRODUCT CARD ---- */
.product-card {
    background: var(--white);
    border-radius: 12px;
    padding: 18px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: box-shadow 0.2s;
}
.product-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.product-name { font-size: 0.9rem; font-weight: 700; color: var(--primary); }
.product-category { font-size: 0.72rem; color: var(--accent); font-weight: 600; text-transform: uppercase; }
.product-presentation { font-size: 0.78rem; color: var(--text-light); }
.product-price { font-size: 1.1rem; font-weight: 800; color: var(--primary); margin-top: 4px; }
.product-stock { font-size: 0.75rem; }
.product-stock.low { color: var(--danger); font-weight: 600; }
.product-stock.ok { color: var(--success); }

/* ---- LOGIN PAGE ---- */
.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 50%, var(--accent) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.login-card {
    background: var(--white);
    border-radius: 20px;
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo .brand-name { font-size: 2.5rem; color: var(--primary); }
.login-logo .brand-tagline { font-size: 0.85rem; color: var(--text-light); }
.login-title { font-size: 1.25rem; font-weight: 700; color: var(--primary); margin-bottom: 6px; }
.login-subtitle { font-size: 0.85rem; color: var(--text-light); margin-bottom: 28px; }

/* ---- EMPTY STATE ---- */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-light);
}
.empty-state i { font-size: 3rem; margin-bottom: 16px; opacity: 0.4; }
.empty-state p { font-size: 0.9rem; }

/* ---- TABS ---- */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--border); margin-bottom: 24px; }
.tab-btn {
    padding: 10px 20px;
    font-family: 'Montserrat', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-light);
    background: none;
    border: none;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}
.tab-btn:hover { color: var(--primary); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--accent); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ---- UPLOAD AREA ---- */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: 10px;
    padding: 32px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s;
    color: var(--text-light);
    font-size: 0.85rem;
}
.upload-area:hover { border-color: var(--accent); color: var(--accent); }
.upload-area i { font-size: 2rem; margin-bottom: 8px; display: block; }

/* ---- STOCK INDICATOR ---- */
.stock-bar { height: 4px; border-radius: 99px; background: var(--border); margin-top: 6px; }
.stock-bar-fill { height: 100%; border-radius: 99px; transition: width 0.3s; }

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--light); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #9CA3AF; }

/* ---- SEARCH BOX ---- */
.search-box {
    position: relative;
    flex: 1;
}
.search-box i {
    position: absolute;
    left: 12px; top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
    font-size: 0.875rem;
}
.search-box input { padding-left: 36px; }

/* ---- DIVIDER ---- */
.divider { height: 1px; background: var(--border); margin: 20px 0; }

/* ---- SPINNER ---- */
.spinner {
    width: 36px; height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- LOADING OVERLAY ---- */
#loading-overlay {
    position: fixed; inset: 0;
    background: rgba(19,41,75,0.7);
    display: flex; align-items: center; justify-content: center;
    z-index: 9999;
}
#loading-overlay .spinner { width: 48px; height: 48px; border-width: 4px; }

/* ---- TREATMENT TIMELINE ---- */
.treatment-progress {
    height: 8px;
    background: var(--border);
    border-radius: 99px;
    overflow: hidden;
    margin: 8px 0;
}
.treatment-progress-bar {
    height: 100%;
    border-radius: 99px;
    background: linear-gradient(90deg, var(--success), var(--accent));
    transition: width 0.3s;
}
.treatment-progress-bar.warning { background: linear-gradient(90deg, var(--warning), var(--danger)); }

/* ---- FLOATING ACTION BUTTON ---- */
.fab {
    position: fixed;
    bottom: max(28px, env(safe-area-inset-bottom, 12px));
    right: max(28px, env(safe-area-inset-right, 12px));
    width: 56px; height: 56px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: 1.25rem;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 16px rgba(19,41,75,0.4);
    cursor: pointer;
    border: none;
    z-index: 200;
    transition: transform 0.2s, box-shadow 0.2s;
}
.fab:hover { transform: scale(1.1); box-shadow: 0 8px 24px rgba(19,41,75,0.4); }

/* ---- ORDER ITEM ---- */
.order-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.order-item:last-child { border-bottom: none; }
.order-item-name { flex: 1; font-size: 0.875rem; font-weight: 500; }
.order-item-qty, .order-item-price { font-size: 0.85rem; color: var(--text-light); width: 80px; text-align: right; }
.order-total { display: flex; justify-content: space-between; padding-top: 12px; font-weight: 700; font-size: 1rem; color: var(--primary); }

/* ---- MOBILE MENU TOGGLE ---- */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--primary);
    cursor: pointer;
}
@media (max-width: 900px) {
    .menu-toggle { display: flex; }
}

/* ---- RESPONSIVE ---- */
@media (max-width: 640px) {
    .page-body {
        padding-top: max(16px, env(safe-area-inset-top, 0px));
        padding-right: max(16px, env(safe-area-inset-right, 0px));
        padding-bottom: max(16px, env(safe-area-inset-bottom, 0px));
        padding-left: max(16px, env(safe-area-inset-left, 0px));
    }
    .login-card { padding: 32px 24px; }
    .login-logo .brand-name { font-size: 2rem; }
    .grid-4 { grid-template-columns: 1fr; }
    .topbar {
        padding-left: max(16px, env(safe-area-inset-left, 0px));
        padding-right: max(16px, env(safe-area-inset-right, 0px));
    }
    .btn:not(.btn-xs):not(.btn-icon) {
        min-height: 44px;
        padding-top: 10px;
        padding-bottom: 10px;
    }
    .form-control, select.form-control {
        min-height: 44px;
    }
}
