/* ============================================
   Turnos Médicos - Custom CSS for Bootstrap 5
   ============================================ */

/* CSS Variables */
:root {
    --primary-color: #0d6efd;
    --secondary-color: #6c757d;
    --success-color: #198754;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #0dcaf0;
    --light-color: #f8f9fa;
    --dark-color: #212529;

    --shadow-sm: 0 .125rem .25rem rgba(0,0,0,.075);
    --shadow: 0 .5rem 1rem rgba(0,0,0,.15);
    --shadow-lg: 0 1rem 3rem rgba(0,0,0,.175);

    --border-radius: 0.375rem;
    --transition: all 0.2s ease-in-out;
}

/* ============================================
   General Styles
   ============================================ */
body {
    background-color: #f5f7fa;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ============================================
   Navbar Styles
   ============================================ */
.navbar {
    box-shadow: var(--shadow-sm);
    padding: 0.5rem 1rem;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
    color: var(--dark-color) !important;
}

.navbar-brand img {
    height: 50px;
}

.navbar .nav-link {
    padding: 0.5rem 1rem;
    color: var(--secondary-color);
    transition: var(--transition);
}

.navbar .nav-link:hover {
    color: var(--primary-color);
}

.navbar .badge {
    font-size: 0.7rem;
    padding: 0.35em 0.5em;
    vertical-align: middle;
}

/* ============================================
   Card Styles (replacing panels)
   ============================================ */
.card {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow);
}

.card-header {
    background-color: var(--light-color);
    border-bottom: 1px solid rgba(0,0,0,.08);
    font-weight: 600;
    padding: 1rem 1.25rem;
}

.card-body {
    padding: 1.25rem;
}

/* Sidebar Card */
.card-sidebar {
    position: sticky;
    top: 80px;
}

/* ============================================
   Datepicker Styles (Bootstrap 5 compatible)
   ============================================ */
.datepicker {
    padding: 10px;
}

.datepicker table {
    width: 100%;
}

.datepicker td,
.datepicker th {
    text-align: center;
    padding: 0.5rem;
    border-radius: var(--border-radius);
}

.datepicker td.day:hover {
    background-color: var(--light-color);
    cursor: pointer;
}

.datepicker td.active,
.datepicker td.active:hover {
    background-color: var(--primary-color);
    color: white;
}

.datepicker td.today {
    background-color: rgba(13, 110, 253, 0.1);
}

.datepicker td.disabled {
    color: #ccc;
}

/* ============================================
   Table Styles
   ============================================ */
.table-turnos-container {
    max-height: calc(100vh - 280px);
    min-height: 400px;
    overflow-y: auto;
    border-radius: var(--border-radius);
}

.table-turnos {
    margin-bottom: 0;
}

.table-turnos thead {
    position: sticky;
    top: 0;
    background-color: var(--light-color);
    z-index: 10;
}

.table-turnos thead th {
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    color: var(--secondary-color);
    border-bottom: 2px solid #dee2e6;
    padding: 0.75rem;
    white-space: nowrap;
}

.table-turnos tbody tr {
    transition: var(--transition);
}

.table-turnos tbody tr:hover {
    background-color: rgba(13, 110, 253, 0.04);
}

.table-turnos td {
    vertical-align: middle;
    padding: 0.625rem 0.75rem;
    font-size: 0.9rem;
}

/* Row states */
.table-turnos tr.row-sobreturno {
    background-color: rgba(220, 53, 69, 0.08) !important;
    border-left: 3px solid var(--danger-color);
}

.table-turnos tr.row-internet {
    background-color: rgba(13, 202, 240, 0.08) !important;
    border-left: 3px solid var(--info-color);
}

.table-turnos tr.row-empty {
    background-color: transparent;
}

.table-turnos tr.row-empty:hover {
    background-color: rgba(25, 135, 84, 0.04);
}

.table-turnos tr.row-nodar {
    background-color: rgba(108, 117, 125, 0.15) !important;
    border-left: 3px solid var(--secondary-color);
    opacity: 0.7;
}

.table-turnos tr.row-nodar td {
    color: var(--secondary-color);
    font-style: italic;
}

.table-turnos tr.row-nodar:hover {
    background-color: rgba(108, 117, 125, 0.2) !important;
}

/* ============================================
   Status Badges
   ============================================ */
.badge-status {
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.4em 0.8em;
    border-radius: 50rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.badge-programado {
    background-color: var(--info-color);
    color: #000;
}

.badge-atendido {
    background-color: var(--success-color);
    color: #fff;
}

.badge-ausente {
    background-color: var(--secondary-color);
    color: #fff;
}

.badge-autorizado {
    background-color: var(--primary-color);
    color: #fff;
}

/* ============================================
   Button Styles
   ============================================ */
.btn {
    font-weight: 500;
    border-radius: var(--border-radius);
    transition: var(--transition);
}

.btn-sm {
    font-size: 0.8rem;
    padding: 0.35rem 0.65rem;
}

/* Action buttons in table */
.btn-action {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

/* Toolbar buttons */
.toolbar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(0,0,0,.08);
}

.toolbar-actions .btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

/* ============================================
   Dropdown Styles
   ============================================ */
.dropdown-menu {
    border: none;
    box-shadow: var(--shadow);
    border-radius: var(--border-radius);
    padding: 0.5rem;
}

.dropdown-item {
    border-radius: calc(var(--border-radius) - 2px);
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

.dropdown-item:hover {
    background-color: var(--light-color);
}

/* Status dropdown */
.dropdown-status .dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ============================================
   Modal Styles
   ============================================ */
.modal-content {
    border: none;
    border-radius: 0.5rem;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    border-bottom: 1px solid rgba(0,0,0,.08);
    padding: 1rem 1.5rem;
}

.modal-title {
    font-weight: 600;
    font-size: 1.1rem;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    border-top: 1px solid rgba(0,0,0,.08);
    padding: 1rem 1.5rem;
}

/* ============================================
   Form Styles
   ============================================ */
.form-control {
    border-radius: var(--border-radius);
    border-color: #dee2e6;
    padding: 0.5rem 0.875rem;
    transition: var(--transition);
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.15);
}

.form-select {
    border-radius: var(--border-radius);
    padding: 0.5rem 0.875rem;
}

.form-label {
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--secondary-color);
    margin-bottom: 0.35rem;
}

.input-group-text {
    background-color: var(--light-color);
    border-color: #dee2e6;
}

/* Fieldset visual grouping */
.fieldset-group {
    background-color: var(--light-color);
    border-radius: var(--border-radius);
    padding: 1rem;
    margin-bottom: 1rem;
}

.fieldset-group-title {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--secondary-color);
    margin-bottom: 0.75rem;
}

/* Patient selection indicator */
.patient-selected {
    background-color: rgba(25, 135, 84, 0.1);
    border: 1px solid rgba(25, 135, 84, 0.3);
    border-radius: var(--border-radius);
    padding: 0.75rem 1rem;
    margin-top: 0.5rem;
}

.patient-selected i {
    color: var(--success-color);
}

/* ============================================
   Alert Styles
   ============================================ */
.alert {
    border: none;
    border-radius: var(--border-radius);
}

.alert-danger-alt {
    background-color: #E26868;
    border-color: #B63E5A;
    color: #fff;
}

/* Toast notifications */
.toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 1100;
}

/* ============================================
   Loading States
   ============================================ */
.loading-spinner {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.loading-spinner .spinner-border {
    width: 1rem;
    height: 1rem;
}

/* Skeleton loading */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: var(--border-radius);
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ============================================
   Reference badges
   ============================================ */
.references {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 0.75rem 0;
    margin-top: 1rem;
    border-top: 1px solid rgba(0,0,0,.08);
}

.reference-item {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--secondary-color);
}

.reference-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.reference-dot.sobreturno {
    background-color: var(--danger-color);
}

.reference-dot.internet {
    background-color: var(--info-color);
}

.reference-dot.nodar {
    background-color: var(--secondary-color);
}

/* Badge info for sessions */
.badge-info-sessions {
    background-color: rgba(13, 110, 253, 0.1);
    color: var(--primary-color);
    border: 1px solid rgba(13, 110, 253, 0.3);
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0.5rem 0.75rem;
    border-radius: var(--border-radius);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

/* ============================================
   WhatsApp indicators
   ============================================ */
.wapp-indicator {
    font-size: 0.9rem;
    cursor: help;
}

/* ============================================
   Session button
   ============================================ */
.btn-session {
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
}

/* ============================================
   ART Label
   ============================================ */
.badge-art {
    background-color: var(--warning-color);
    color: #000;
    font-size: 0.7rem;
    font-weight: 600;
}

/* ============================================
   Responsive Styles
   ============================================ */
@media (max-width: 991.98px) {
    .table-turnos-container {
        max-height: calc(100vh - 200px);
    }

    .card-sidebar {
        position: relative;
        top: 0;
        margin-bottom: 1rem;
    }
}

@media (max-width: 767.98px) {
    .navbar-brand {
        font-size: 0.9rem;
    }

    .navbar-brand img {
        height: 40px;
    }

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

    .toolbar-actions .btn {
        width: 100%;
        justify-content: center;
    }

    .table-turnos {
        font-size: 0.8rem;
    }

    .table-turnos td,
    .table-turnos th {
        padding: 0.5rem;
    }

    /* Hide less important columns on mobile */
    .table-turnos .col-hide-mobile {
        display: none;
    }

    .references {
        flex-direction: column;
        gap: 0.5rem;
    }
}

/* ============================================
   Print Styles
   ============================================ */
@media print {
    .navbar,
    .btn,
    .dropdown,
    .hidden-print,
    .d-print-none {
        display: none !important;
    }

    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }

    .table-turnos-container {
        max-height: none;
        overflow: visible;
    }
}

/* ============================================
   Bootstrap Icons inline utility
   ============================================ */
.bi {
    vertical-align: -0.125em;
}

/* ============================================
   Utilities
   ============================================ */
.cursor-pointer {
    cursor: pointer;
}

.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
