/* =====================================================================
   POLICLÍNICA BANCARIA (POBA) - CONTROL DE REPARACIONES Y PREVENTIVO
   Identidad Visual CPyEM / POBA System Design
   ===================================================================== */

:root {
    --poba-blue: #1d70b8;
    --poba-blue-hover: #155893;
    --poba-blue-light: #eef6fc;
    --poba-purple: #5b52f6;
    --poba-purple-hover: #4840d6;
    --poba-green: #10b981;
    --poba-green-hover: #059669;
    --poba-red: #ef4444;
    --poba-orange: #f59e0b;
    --poba-bg: #f8fafc;
    --poba-sidebar-bg: #ffffff;
    --poba-border: #e2e8f0;
    --poba-text-main: #1e293b;
    --poba-text-muted: #64748b;
    --sidebar-width: 260px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--poba-bg);
    color: var(--poba-text-main);
    overflow-x: hidden;
}

/* ---------------------------------------------------------------------
   SIDEBAR & POBA NAVIGATION
   --------------------------------------------------------------------- */
.app-wrapper {
    display: flex;
    min-height: 100vh;
    position: relative;
}

.sidebar {
    width: var(--sidebar-width);
    background-color: var(--poba-sidebar-bg);
    border-right: 1px solid var(--poba-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1050;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.05);
}

/* Telón de fondo oscuro para móvil/tablet al abrir Drawer */
.sidebar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(2px);
    z-index: 1040;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.sidebar-backdrop.show {
    opacity: 1;
    visibility: visible;
}

.sidebar-header {
    padding: 1.25rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    border-bottom: 1px solid var(--poba-border);
}

.sidebar-brand-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    overflow: hidden;
}

.sidebar-brand-logo {
    height: 44px;
    width: auto;
    object-fit: contain;
}

.sidebar-brand-title {
    font-weight: 800;
    font-size: 1.15rem;
    color: #0f172a;
    line-height: 1.1;
}

.sidebar-brand-sub {
    font-size: 0.725rem;
    color: var(--poba-text-muted);
    font-weight: 500;
}

.btn-sidebar-close {
    display: none;
    background: transparent;
    border: none;
    color: var(--poba-text-muted);
    font-size: 1.25rem;
    padding: 0.4rem;
    cursor: pointer;
    border-radius: 0.5rem;
    line-height: 1;
}

.btn-sidebar-close:hover {
    color: var(--poba-red);
    background-color: #fee2e2;
}

.sidebar-nav {
    padding: 1rem 0.75rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.nav-link-poba {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.75rem 1rem;
    min-height: 44px;
    color: #475569;
    font-weight: 500;
    font-size: 0.925rem;
    border-radius: 0.75rem;
    text-decoration: none;
    transition: all 0.2s ease;
}

.nav-link-poba i {
    font-size: 1.15rem;
    color: #64748b;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
}

.nav-link-poba:hover {
    background-color: #f1f5f9;
    color: var(--poba-blue);
}

.nav-link-poba:hover i {
    color: var(--poba-blue);
}

.nav-link-poba.active {
    background-color: #ebf5ff;
    color: var(--poba-blue);
    font-weight: 700;
}

.nav-link-poba.active i {
    color: var(--poba-blue);
}

.nav-link-poba.logout {
    color: var(--poba-red);
}

.nav-link-poba.logout i {
    color: var(--poba-red);
}

.user-badge-container {
    padding: 0.85rem 1.25rem;
    background-color: #f8fafc;
    border-top: 1px solid var(--poba-border);
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-avatar-circle {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #cbd5e1 0%, #94a3b8 100%);
    color: #ffffff;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    flex-shrink: 0;
}

.user-details {
    overflow: hidden;
    flex-grow: 1;
}

.user-name {
    font-size: 0.825rem;
    font-weight: 700;
    color: #0f172a;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.user-role-badge {
    font-size: 0.7rem;
    color: var(--poba-text-muted);
}

/* ---------------------------------------------------------------------
   MAIN CONTENT AREA & HEADER
   --------------------------------------------------------------------- */
.main-content {
    margin-left: var(--sidebar-width);
    flex-grow: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    width: calc(100% - var(--sidebar-width));
}

.sidebar.collapsed {
    transform: translateX(-100%);
}

.main-content.expanded {
    margin-left: 0 !important;
    width: 100% !important;
}

.top-navbar {
    height: 66px;
    background-color: #ffffff;
    border-bottom: 1px solid var(--poba-border);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 900;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.top-nav-title {
    font-weight: 700;
    font-size: 1.1rem;
    color: #334155;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-sidebar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    min-height: 42px;
    background-color: var(--poba-blue-light);
    color: var(--poba-blue);
    border: 1.5px solid rgba(29, 112, 184, 0.3);
    padding: 0.4rem 0.75rem;
    border-radius: 0.65rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

.btn-sidebar-toggle:hover {
    background-color: var(--poba-blue);
    color: #ffffff;
    border-color: var(--poba-blue);
    box-shadow: 0 4px 10px rgba(29, 112, 184, 0.3);
    transform: translateY(-1px);
}

.btn-sidebar-toggle i {
    font-size: 1.15rem;
}

.btn-return-portal {
    background-color: #0284c7;
    color: #ffffff;
    border: none;
    border-radius: 50rem;
    padding: 0.45rem 1rem;
    min-height: 38px;
    font-weight: 600;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    text-decoration: none;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn-return-portal:hover {
    background-color: #0369a1;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.25);
}

.content-body {
    padding: 1.75rem;
    flex-grow: 1;
}

/* ---------------------------------------------------------------------
   METRIC CARDS (KPIs)
   --------------------------------------------------------------------- */
.kpi-card {
    background: #ffffff;
    border: 1px solid var(--poba-border);
    border-radius: 1rem;
    padding: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    height: 100%;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.05);
}

.kpi-number {
    font-size: 1.9rem;
    font-weight: 800;
    color: #0f172a;
    line-height: 1;
    margin-bottom: 0.25rem;
}

.kpi-label {
    font-size: 0.725rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--poba-text-muted);
}

.kpi-icon-wrapper {
    width: 48px;
    height: 48px;
    border-radius: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.kpi-icon-wrapper.purple {
    background-color: #f3e8ff;
    color: #9333ea;
}

.kpi-icon-wrapper.green {
    background-color: #dcfce7;
    color: #16a34a;
}

.kpi-icon-wrapper.red {
    background-color: #ffe4e6;
    color: #e11d48;
}

.kpi-icon-wrapper.blue {
    background-color: #e0f2fe;
    color: #0284c7;
}

/* ---------------------------------------------------------------------
   CONTAINER CARDS & SEARCH FILTERS
   --------------------------------------------------------------------- */
.poba-card {
    background: #ffffff;
    border: 1px solid var(--poba-border);
    border-radius: 1rem;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.poba-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.poba-card-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.poba-card-title i {
    color: var(--poba-blue);
}

.btn-poba-purple {
    background-color: var(--poba-purple);
    color: #ffffff;
    font-weight: 600;
    border-radius: 0.6rem;
    padding: 0.5rem 1.1rem;
    min-height: 38px;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    text-decoration: none;
    transition: all 0.2s;
}

.btn-poba-purple:hover {
    background-color: var(--poba-purple-hover);
    color: #ffffff;
}

.btn-poba-excel {
    background-color: var(--poba-green);
    color: #ffffff;
    font-weight: 600;
    border-radius: 0.6rem;
    padding: 0.5rem 1rem;
    min-height: 38px;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    text-decoration: none;
    transition: all 0.2s;
}

.btn-poba-excel:hover {
    background-color: var(--poba-green-hover);
    color: #ffffff;
}

.btn-poba-print {
    background-color: #0284c7;
    color: #ffffff;
    font-weight: 600;
    border-radius: 0.6rem;
    padding: 0.5rem 1rem;
    min-height: 38px;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    transition: all 0.2s;
}

.btn-poba-print:hover {
    background-color: #0369a1;
    color: #ffffff;
}

/* ---------------------------------------------------------------------
   DATA TABLES & RESPONSIVE SCROLL
   --------------------------------------------------------------------- */
.table-responsive {
    -webkit-overflow-scrolling: touch;
    overflow-x: auto;
    border-radius: 0.75rem;
}

.table-poba {
    width: 100%;
    margin-bottom: 0;
    border-collapse: separate;
    border-spacing: 0;
}

.table-poba th {
    background-color: #f8fafc;
    color: #475569;
    font-weight: 700;
    font-size: 0.825rem;
    text-transform: capitalize;
    padding: 0.85rem 0.9rem;
    border-bottom: 1px solid var(--poba-border);
    border-top: 1px solid var(--poba-border);
    white-space: nowrap;
}

.table-poba td {
    padding: 0.85rem 0.9rem;
    vertical-align: middle;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--poba-border);
    color: #334155;
}

.table-poba tbody tr:hover {
    background-color: #f8fafc;
}

.badge-status {
    padding: 0.35rem 0.75rem;
    border-radius: 50rem;
    font-size: 0.75rem;
    font-weight: 700;
    display: inline-block;
    white-space: nowrap;
}

.badge-status.pendiente {
    background-color: #fef3c7;
    color: #d97706;
}

.badge-status.proceso {
    background-color: #e0f2fe;
    color: #0284c7;
}

.badge-status.cerrado {
    background-color: #dcfce7;
    color: #16a34a;
}

.badge-status.anulado {
    background-color: #fee2e2;
    color: #dc2626;
}

.ticket-number-link {
    color: var(--poba-blue);
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}

.ticket-number-link:hover {
    text-decoration: underline;
}

/* Touch friendly form inputs */
.form-control, .form-select {
    min-height: 42px;
    font-size: 0.925rem;
    border-radius: 0.6rem;
    border-color: var(--poba-border);
}

.form-control:focus, .form-select:focus {
    border-color: var(--poba-blue);
    box-shadow: 0 0 0 3px rgba(29, 112, 184, 0.15);
}

/* ---------------------------------------------------------------------
   MEDIA QUERIES: TABLETS & MOBILE DEVICES
   --------------------------------------------------------------------- */

/* TABLETS Y DISPOSITIVOS MEDIANOS (< 992px) */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
        box-shadow: 0 0 25px rgba(0, 0, 0, 0.2);
    }

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

    .btn-sidebar-close {
        display: block;
    }

    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
    }

    .top-navbar {
        padding: 0 1rem;
        height: 62px;
    }

    .content-body {
        padding: 1.25rem 1rem;
    }

    .poba-card {
        padding: 1.25rem;
        margin-bottom: 1.25rem;
    }
}

/* CELULARES Y SMARTPHONES (< 576px) */
@media (max-width: 575.98px) {
    .content-body {
        padding: 0.85rem 0.65rem;
    }

    .top-navbar {
        padding: 0 0.75rem;
        height: 58px;
    }

    .top-nav-title {
        font-size: 0.95rem;
        max-width: 150px;
    }

    .btn-sidebar-toggle {
        min-width: 38px;
        min-height: 38px;
        padding: 0.35rem 0.55rem;
        font-size: 0.9rem;
    }

    .btn-return-portal {
        padding: 0.35rem 0.75rem;
        font-size: 0.775rem;
        min-height: 34px;
    }

    /* Form inputs sin zoom molesto en iOS (mínimo 16px) */
    .form-control, .form-select, input[type="text"], input[type="date"], textarea {
        font-size: 16px !important;
    }

    /* KPI Cards en móviles */
    .kpi-card {
        padding: 0.9rem 0.75rem;
        border-radius: 0.85rem;
    }

    .kpi-number {
        font-size: 1.5rem;
    }

    .kpi-label {
        font-size: 0.675rem;
    }

    .kpi-icon-wrapper {
        width: 40px;
        height: 40px;
        font-size: 1.05rem;
        border-radius: 0.65rem;
    }

    .poba-card {
        padding: 1rem 0.75rem;
        border-radius: 0.85rem;
        margin-bottom: 1rem;
    }

    .poba-card-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.6rem;
    }

    .poba-card-header .d-flex {
        flex-wrap: wrap;
        width: 100%;
    }

    .poba-card-header .btn, 
    .poba-card-header .btn-poba-purple,
    .poba-card-header .btn-poba-excel,
    .poba-card-header .btn-poba-print {
        flex: 1 1 auto;
        font-size: 0.825rem;
        padding: 0.45rem 0.75rem;
    }

    .table-poba th, .table-poba td {
        padding: 0.65rem 0.55rem;
        font-size: 0.8rem;
    }

    /* Modal en celulares */
    .modal-dialog {
        margin: 0.5rem;
    }
}

/* ---------------------------------------------------------------------
   PRINT STYLESHEET (PDF CLEAN PRINT)
   --------------------------------------------------------------------- */
@media print {
    .sidebar, .top-navbar, .sidebar-backdrop, .poba-card-header .btn, .search-filter-section, .no-print {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }

    .content-body {
        padding: 0 !important;
    }

    .poba-card {
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
    }

    body {
        background-color: #ffffff !important;
        color: #000000 !important;
    }
}

