/* 
 * HistoClinik - Modern Override Stylesheet
 * Applied over MDBootstrap/Bootstrap to modernize layout and components.
 */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

:root {
    --primary-color: #6366f1; /* Royal Indigo */
    --primary-hover: #4f46e5;
    --primary-light: rgba(99, 102, 241, 0.12);
    
    --secondary-color: #0ea5e9; /* Teal/Cyan Blue */
    --accent-color: #10b981; /* Success Emerald */
    --warning-color: #f59e0b; /* Amber */
    --danger-color: #ef4444; /* Rose/Red */
    
    --dark-bg: #0b0f19; /* Sleek Deep Charcoal for Sidebar */
    --dark-surface: #111827;
    --light-bg: #f8fafc; /* Minimal zinc bg for main page */
    --card-bg: #ffffff;
    
    --font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    --border-radius: 12px;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Clean soft modern shadows */
    --box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.03), 0 8px 10px -6px rgba(0, 0, 0, 0.03);
    --box-shadow-hover: 0 20px 30px -10px rgba(99, 102, 241, 0.08), 0 10px 15px -8px rgba(99, 102, 241, 0.08);
}

/* 1. Global Reset & Typography */
body {
    font-family: var(--font-family) !important;
    background-color: var(--light-bg) !important;
    color: #334155 !important;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6, b, strong {
    font-weight: 700 !important;
    color: #0f172a !important;
    letter-spacing: -0.02em;
}

h2 {
    font-size: 1.65rem !important;
    margin-bottom: 1.5rem !important;
    position: relative;
    display: inline-block;
}

/* 2. Sidebar Modernization */
aside.bg-dark {
    background-color: var(--dark-bg) !important;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

#sidebar {
    background-color: var(--dark-bg) !important;
    padding: 1.5rem 1rem !important;
}

#sidebar .navbar-brand {
    font-size: 1.15rem !important;
    font-weight: 800 !important;
    letter-spacing: -0.03em;
    color: #ffffff !important;
    background: linear-gradient(135deg, #ffffff 0%, #a5b4fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: block !important;
    margin-bottom: 0.5rem;
}

#sidebar img {
    border: 3px solid rgba(99, 102, 241, 0.2) !important;
    box-shadow: 0 0 25px rgba(99, 102, 241, 0.15) !important;
    transition: var(--transition) !important;
    max-height: 80px;
    object-fit: cover;
}

#sidebar img:hover {
    transform: scale(1.05) rotate(2deg);
    border-color: rgba(99, 102, 241, 0.5) !important;
}

#sidebar .nav-link {
    color: #94a3b8 !important;
    font-size: 0.875rem !important;
    font-weight: 500 !important;
    padding: 0.75rem 1rem !important;
    border-radius: var(--border-radius) !important;
    transition: var(--transition) !important;
    margin-bottom: 0.35rem !important;
    display: flex;
    align-items: center;
}

#sidebar .nav-link i {
    font-size: 1.05rem !important;
    width: 1.5rem !important;
    margin-right: 0.5rem !important;
    transition: var(--transition) !important;
    opacity: 0.7;
}

#sidebar .nav-link:hover {
    color: #ffffff !important;
    background-color: rgba(255, 255, 255, 0.05) !important;
    transform: translateX(4px);
}

#sidebar .nav-link:hover i {
    opacity: 1;
}

#sidebar .nav-link.active {
    color: #ffffff !important;
    background: linear-gradient(135deg, var(--primary-color) 0%, #4f46e5 100%) !important;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3) !important;
    font-weight: 600 !important;
}

#sidebar .nav-link.active i {
    color: #ffffff !important;
    opacity: 1;
}

/* Collapsible items in sidebar */
#sidebar .dropdown-toggle::after {
    margin-left: auto !important;
    transition: var(--transition) !important;
}

#sidebar .dropdown-toggle[aria-expanded="true"]::after {
    transform: rotate(180deg) !important;
}

#sidebar ul.collapse {
    padding-left: 0 !important;
    margin-top: 0.25rem !important;
    margin-bottom: 0.5rem !important;
    border-left: 1px dashed rgba(255, 255, 255, 0.12) !important;
    margin-left: 1.5rem !important;
}

#sidebar ul.collapse .nav-item {
    margin-left: 0 !important;
}

#sidebar ul.collapse .nav-link {
    padding: 0.5rem 1rem !important;
    font-size: 0.825rem !important;
    margin-bottom: 0.15rem !important;
    color: #64748b !important;
}

#sidebar ul.collapse .nav-link.active {
    color: #ffffff !important;
    background: rgba(99, 102, 241, 0.15) !important;
    box-shadow: none !important;
}

/* Logout Button */
#sidebar button.no-button {
    width: 100%;
    text-align: left;
    color: #f87171 !important;
    border-radius: var(--border-radius) !important;
    padding: 0.75rem 1rem !important;
    transition: var(--transition) !important;
    display: flex;
    align-items: center;
    background: transparent;
    border: none;
    font-size: 0.875rem !important;
    font-weight: 500 !important;
}

#sidebar button.no-button i {
    font-size: 1.05rem !important;
    width: 1.5rem !important;
    margin-right: 0.5rem !important;
}

#sidebar button.no-button:hover {
    color: #ffffff !important;
    background-color: rgba(239, 68, 68, 0.15) !important;
    transform: translateX(4px);
}

/* 3. Main Container */
main.bg-light {
    background-color: var(--light-bg) !important;
}

main .container {
    padding: 2rem !important;
    max-width: 1440px !important;
}

/* 4. Cards Modernization */
.card {
    background-color: var(--card-bg) !important;
    border: 1px solid rgba(226, 232, 240, 0.8) !important;
    border-radius: var(--border-radius) !important;
    box-shadow: var(--box-shadow) !important;
    transition: var(--transition) !important;
    padding: 1.5rem !important;
    overflow: hidden;
}

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

.card hr {
    border-top: 1px solid #e2e8f0 !important;
    opacity: 0.6 !important;
    margin: 1.5rem 0 !important;
}

/* Card Header Overrides (For lists, search panels, etc.) */
.card .card-header,
.card div[class*="bg-dark"].text-white {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%) !important;
    border-radius: 8px !important;
    margin: -1.5rem -1.5rem 1.5rem -1.5rem !important;
    padding: 1rem 1.5rem !important;
    font-weight: 700 !important;
    letter-spacing: -0.01em;
}

/* 5. Buttons Modernization */
.btn {
    border-radius: 8px !important;
    padding: 0.625rem 1.25rem !important;
    font-size: 0.85rem !important;
    font-weight: 600 !important;
    text-transform: none !important; /* Disables MDBootstrap forced uppercase */
    box-shadow: none !important;
    transition: var(--transition) !important;
    letter-spacing: 0px !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn:active, .btn:focus {
    box-shadow: none !important;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%) !important;
    border: none !important;
    color: #ffffff !important;
}

.btn-primary:hover, .btn-primary:focus {
    background: linear-gradient(135deg, var(--primary-hover) 0%, #4338ca 100%) !important;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.3) !important;
    transform: translateY(-1px);
}

.btn-azul {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%) !important;
    border: none !important;
    color: #ffffff !important;
}

.btn-azul:hover {
    background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%) !important;
    box-shadow: 0 4px 14px rgba(59, 130, 246, 0.3) !important;
    transform: translateY(-1px);
}

.btn-dark {
    background-color: #0f172a !important;
    border: none !important;
    color: #ffffff !important;
}

.btn-dark:hover {
    background-color: #1e293b !important;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.2) !important;
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: #f1f5f9 !important;
    border: 1px solid #e2e8f0 !important;
    color: #475569 !important;
}

.btn-secondary:hover {
    background-color: #e2e8f0 !important;
    color: #0f172a !important;
}

.btn-warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%) !important;
    border: none !important;
    color: #ffffff !important;
}

.btn-warning:hover {
    box-shadow: 0 4px 14px rgba(245, 158, 11, 0.3) !important;
    transform: translateY(-1px);
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%) !important;
    border: none !important;
    color: #ffffff !important;
}

.btn-danger:hover {
    box-shadow: 0 4px 14px rgba(239, 68, 68, 0.3) !important;
    transform: translateY(-1px);
}

.btn-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
    border: none !important;
    color: #ffffff !important;
}

.btn-success:hover {
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.3) !important;
    transform: translateY(-1px);
}

/* 6. Form Fields Modernization */
.form-label {
    font-weight: 600 !important;
    color: #475569 !important;
    font-size: 0.85rem !important;
    margin-bottom: 0.375rem !important;
}

.form-control, .form-select {
    border-radius: 8px !important;
    border: 1px solid #cbd5e1 !important;
    padding: 0.625rem 0.875rem !important;
    font-size: 0.9rem !important;
    color: #0f172a !important;
    background-color: #ffffff !important;
    transition: var(--transition) !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02) !important;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-color) !important;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.12) !important;
    outline: none !important;
}

.form-check-input {
    border-radius: 4px !important;
    border-color: #cbd5e1 !important;
    cursor: pointer !important;
}

.form-check-input:checked {
    background-color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
}

/* Floating labels adjustments (auth pages) */
.form-floating > .form-control:focus ~ label,
.form-floating > .form-control:not(:placeholder-shown) ~ label,
.form-floating > .form-select ~ label {
    color: var(--primary-color) !important;
    opacity: 0.85 !important;
    transform: scale(0.85) translateY(-0.5rem) translateX(0.15rem) !important;
}

/* MDBootstrap form-outline specifics override */
.form-outline .form-control {
    border-bottom: 1px solid #cbd5e1 !important;
}

.form-outline .form-control:focus ~ .form-notch .form-notch-middle {
    border-top-color: var(--primary-color) !important;
    border-bottom-color: var(--primary-color) !important;
}

.form-outline .form-control:focus ~ .form-notch .form-notch-leading,
.form-outline .form-control:focus ~ .form-notch .form-notch-trailing {
    border-color: var(--primary-color) !important;
}

.form-outline .form-control:focus ~ label {
    color: var(--primary-color) !important;
}

/* 7. Alerts & Notifications */
.alert {
    border: none !important;
    border-radius: var(--border-radius) !important;
    padding: 1.25rem !important;
    font-size: 0.9rem !important;
    box-shadow: var(--box-shadow) !important;
    position: relative !important;
    overflow: hidden !important;
    margin-bottom: 1.5rem !important;
}

.alert::before {
    content: '' !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 5px !important;
    height: 100% !important;
}

.alert-primary {
    background-color: rgba(99, 102, 241, 0.08) !important;
    color: #4338ca !important;
    border: 1px solid rgba(99, 102, 241, 0.15) !important;
}

.alert-primary::before {
    background-color: var(--primary-color) !important;
}

.alert-secondary {
    background-color: rgba(71, 85, 105, 0.06) !important;
    color: #334155 !important;
    border: 1px solid rgba(71, 85, 105, 0.12) !important;
}

.alert-secondary::before {
    background-color: #475569 !important;
}

.alert-info {
    background-color: rgba(14, 165, 233, 0.08) !important;
    color: #0369a1 !important;
    border: 1px solid rgba(14, 165, 233, 0.15) !important;
}

.alert-info::before {
    background-color: var(--secondary-color) !important;
}

.alert-success {
    background-color: rgba(16, 185, 129, 0.08) !important;
    color: #065f46 !important;
    border: 1px solid rgba(16, 185, 129, 0.15) !important;
}

.alert-success::before {
    background-color: var(--accent-color) !important;
}

.alert-warning {
    background-color: rgba(245, 158, 11, 0.08) !important;
    color: #92400e !important;
    border: 1px solid rgba(245, 158, 11, 0.15) !important;
}

.alert-warning::before {
    background-color: var(--warning-color) !important;
}

.alert-danger {
    background-color: rgba(239, 68, 68, 0.08) !important;
    color: #991b1b !important;
    border: 1px solid rgba(239, 68, 68, 0.15) !important;
}

.alert-danger::before {
    background-color: var(--danger-color) !important;
}

.alert strong {
    font-weight: 700 !important;
    color: inherit !important;
}

/* 8. Tables Modernization */
.table-responsive {
    border-radius: var(--border-radius) !important;
    border: 1px solid #e2e8f0 !important;
    overflow: hidden !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.01) !important;
}

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

.table th {
    background-color: #f8fafc !important;
    color: #475569 !important;
    font-weight: 700 !important;
    font-size: 0.75rem !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
    padding: 1rem 1.25rem !important;
    border-bottom: 2px solid #e2e8f0 !important;
}

.table td {
    padding: 1rem 1.25rem !important;
    font-size: 0.875rem !important;
    color: #334155 !important;
    vertical-align: middle !important;
    border-bottom: 1px solid #f1f5f9 !important;
    background-color: #ffffff !important;
}

.table-striped tbody tr:nth-of-type(odd) td {
    background-color: #f8fafc !important;
}

.table-striped tbody tr:hover td {
    background-color: rgba(99, 102, 241, 0.03) !important;
}

/* 9. Modals Modernization */
.modal-content {
    border-radius: 16px !important;
    border: none !important;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15) !important;
    overflow: hidden !important;
}

.modal-header {
    border-bottom: 1px solid #f1f5f9 !important;
    padding: 1.25rem 1.5rem !important;
    background-color: #ffffff !important;
}

.modal-title {
    font-size: 1.1rem !important;
    font-weight: 700 !important;
    color: #0f172a !important;
}

.modal-body {
    padding: 1.5rem !important;
    font-size: 0.95rem !important;
    color: #334155 !important;
}

.modal-footer {
    border-top: 1px solid #f1f5f9 !important;
    padding: 1rem 1.5rem !important;
    background-color: #f8fafc !important;
}

/* 10. Auth Screens and Guest Layout Overrides */
body[style*="background-color: #57a3fd"], 
body[style*="background-color:#57a3fd"],
body.bg-azul,
body.auth-page-body {
    background: radial-gradient(circle at top right, rgba(99, 102, 241, 0.15), transparent 600px), 
                radial-gradient(circle at bottom left, rgba(14, 165, 233, 0.15), transparent 600px),
                linear-gradient(135deg, #0f172a 0%, #0b0f19 100%) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-height: 100vh !important;
    padding: 1.5rem !important;
}

body[style*="background-color: #57a3fd"] .container,
body[style*="background-color:#57a3fd"] .container,
body.bg-azul .container,
body.auth-page-body .container {
    max-width: 480px !important;
    width: 100% !important;
    margin: auto !important;
}

body[style*="background-color: #57a3fd"] .card,
body[style*="background-color:#57a3fd"] .card,
body.bg-azul .card,
body.bg-azul div.row.card,
body.auth-page-body .card {
    background-color: rgba(255, 255, 255, 0.96) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    border-radius: 20px !important;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4) !important;
    padding: 2.5rem !important;
    backdrop-filter: blur(8px) !important;
    -webkit-backdrop-filter: blur(8px) !important;
}

body[style*="background-color: #57a3fd"] .card img,
body[style*="background-color:#57a3fd"] .card img,
body.bg-azul .card img,
body.auth-page-body .card img {
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.05)) !important;
    max-height: 140px !important;
    width: auto !important;
    margin-bottom: 2rem !important;
}

/* 11. Table Responsive Horizontal Scroll on Mobile */
@media (max-width: 768px) {
    .table-responsive {
        width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        border: 1px solid #e2e8f0 !important;
    }
    
    table {
        min-width: 650px !important; /* Forces horizontal scroll bar on mobile by ensuring minimum room */
        display: table !important; /* Keep original table behavior */
    }
    
    /* Alternate: If the table has no .table-responsive wrapper, force horizontal scroll directly */
    table:not(.table-responsive > table) {
        display: block !important;
        width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
}
