/* ============================================
   Sistema Dra. Adriana Fajardo
   Pediatra Neonatóloga - Custom Styles
   Complete component library (no Bootstrap)
   ============================================ */

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

/* ---- CSS Variables ---- */
:root {
    --turquesa: #3AA6A6;
    --turquesa-dark: #2d8a8a;
    --morado: #6C4A63;
    --morado-light: #8B5E83;
    --bg-light: #f8f9fa;
    --bg-body: #f5f7fa;
    --border-color: #e0e0e0;
    --text-dark: #333;
    --text-muted: #888;
    --white: #fff;
    --danger: #dc3545;
    --success: #28a745;
    --font: 'Poppins', 'Segoe UI', sans-serif;
}

/* ---- Base Reset ---- */
*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font);
    font-size: 0.92rem;
    color: var(--text-dark);
    background: var(--bg-body);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--turquesa);
    text-decoration: none;
}

a:hover {
    color: var(--turquesa-dark);
}

img {
    max-width: 100%;
    height: auto;
}

/* ============================================
   TOP NAVBAR
   ============================================ */
.top-navbar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 64px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
}

.navbar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1rem;
    color: var(--morado);
}

.navbar-logo img {
    height: 38px;
    width: auto;
}

.navbar-menu {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 4px;
}

.navbar-menu li a {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 500;
    color: #555;
    transition: all 0.2s;
    text-decoration: none;
}

.navbar-menu li a:hover {
    background: rgba(58, 166, 166, 0.08);
    color: var(--turquesa);
}

.navbar-menu li a.active {
    background: linear-gradient(135deg, var(--turquesa), var(--turquesa-dark));
    color: #fff;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--morado), var(--morado-light));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
}

.user-name {
    font-weight: 600;
    font-size: 0.82rem;
    color: var(--text-dark);
}

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

.btn-logout {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 14px;
    border-radius: 10px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--danger);
    background: rgba(220, 53, 69, 0.08);
    text-decoration: none;
    transition: all 0.2s;
    margin-left: 8px;
}

.btn-logout:hover {
    background: rgba(220, 53, 69, 0.15);
    color: var(--danger);
}

/* ============================================
   MAIN LAYOUT (Sidebar + Content)
   ============================================ */
.main-layout {
    display: flex;
    min-height: calc(100vh - 64px);
}

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
    width: 230px;
    min-width: 230px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(8px);
    border-right: 1px solid var(--border-color);
    padding: 24px 16px;
    position: sticky;
    top: 64px;
    height: calc(100vh - 64px);
    overflow-y: auto;
}

.sidebar-title {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    padding: 0 12px;
    margin-bottom: 8px;
}

.sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 0 0 16px 0;
}

.sidebar-menu li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 500;
    color: #555;
    transition: all 0.2s;
    text-decoration: none;
    margin-bottom: 2px;
}

.sidebar-menu li a:hover {
    background: rgba(58, 166, 166, 0.08);
    color: var(--turquesa);
}

.sidebar-menu li a.active {
    background: linear-gradient(135deg, var(--turquesa), var(--turquesa-dark));
    color: #fff;
    box-shadow: 0 4px 12px rgba(58, 166, 166, 0.3);
}

/* ============================================
   PAGE CONTENT
   ============================================ */
.page-content {
    flex: 1;
    padding: 28px 32px;
    min-width: 0;
}

.page-header {
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-dark);
    margin: 0 0 4px 0;
}

.page-header p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: 12px;
    font-family: var(--font);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s;
    text-decoration: none;
    line-height: 1.4;
    white-space: nowrap;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.8rem;
    border-radius: 10px;
}

.btn-turquesa {
    background: linear-gradient(135deg, var(--turquesa), var(--turquesa-dark));
    color: #fff;
    box-shadow: 0 4px 12px rgba(58, 166, 166, 0.25);
}

.btn-turquesa:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(58, 166, 166, 0.35);
    color: #fff;
}

.btn-outline-turquesa {
    background: transparent;
    color: var(--turquesa);
    border: 1.5px solid var(--turquesa);
}

.btn-outline-turquesa:hover {
    background: var(--turquesa);
    color: #fff;
}

.btn-outline-morado {
    background: transparent;
    color: var(--morado);
    border: 1.5px solid var(--morado);
}

.btn-outline-morado:hover {
    background: var(--morado);
    color: #fff;
}

.btn-danger-soft {
    background: rgba(220, 53, 69, 0.1);
    color: var(--danger);
    border: 1.5px solid transparent;
}

.btn-danger-soft:hover {
    background: var(--danger);
    color: #fff;
}

/* ============================================
   CARDS
   ============================================ */
.card-custom {
    background: var(--white);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    border: 1px solid rgba(0, 0, 0, 0.04);
}

/* ============================================
   STAT CARDS
   ============================================ */
.stat-card {
    background: var(--white);
    border-radius: 16px;
    padding: 24px;
    text-align: center;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    border: 1px solid rgba(0, 0, 0, 0.04);
    position: relative;
    overflow: hidden;
    transition: transform 0.3s, box-shadow 0.3s;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    margin: 0 auto 12px auto;
}

.stat-icon.turquesa {
    background: rgba(58, 166, 166, 0.12);
    color: var(--turquesa);
}

.stat-icon.morado {
    background: rgba(108, 74, 99, 0.12);
    color: var(--morado);
}

.stat-number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-dark);
    line-height: 1.1;
}

.stat-label {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ============================================
   TABLES
   ============================================ */
.table-custom {
    width: 100%;
    border-collapse: collapse;
}

.table-custom thead th {
    padding: 12px 14px;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border-color);
    text-align: left;
}

.table-custom tbody td {
    padding: 12px 14px;
    font-size: 0.88rem;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
}

.table-custom tbody tr:hover {
    background: rgba(58, 166, 166, 0.03);
}

/* ============================================
   BADGES
   ============================================ */
.badge-turquesa {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    background: rgba(58, 166, 166, 0.12);
    color: var(--turquesa-dark);
}

.badge-morado {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    background: rgba(108, 74, 99, 0.12);
    color: var(--morado);
}

/* ============================================
   ALERTS
   ============================================ */
.alert-custom {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    border-radius: 12px;
    font-size: 0.88rem;
    font-weight: 500;
}

.alert-custom.alert-success {
    background: rgba(40, 167, 69, 0.1);
    color: #1a6b2f;
    border: 1px solid rgba(40, 167, 69, 0.2);
}

.alert-custom.alert-danger {
    background: rgba(220, 53, 69, 0.1);
    color: #a12232;
    border: 1px solid rgba(220, 53, 69, 0.2);
}

/* ============================================
   EMPTY STATE
   ============================================ */
.empty-state {
    text-align: center;
    padding: 50px 20px;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 3.5rem;
    display: block;
    margin-bottom: 12px;
    opacity: 0.4;
}

.empty-state h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-dark);
    margin: 0 0 6px 0;
}

.empty-state p {
    font-size: 0.85rem;
    margin: 0;
}

/* ============================================
   FORM SECTIONS
   ============================================ */
.form-section {
    background: var(--white);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    border: 1px solid rgba(0, 0, 0, 0.04);
}

.form-section .section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
    font-weight: 700;
    color: var(--morado);
    margin-bottom: 18px;
    padding-bottom: 10px;
    border-bottom: 2px solid rgba(108, 74, 99, 0.12);
}

.form-group-custom {
    margin-bottom: 16px;
}

.form-group-custom label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: #555;
    margin-bottom: 6px;
}

/* ============================================
   RECORD DETAIL
   ============================================ */
.record-detail {
    background: var(--white);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    border: 1px solid rgba(0, 0, 0, 0.04);
}

.detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 2px solid var(--border-color);
}

.detail-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-dark);
    margin: 0;
}

.detail-row {
    display: flex;
    padding: 8px 0;
    border-bottom: 1px solid #f5f5f5;
}

.detail-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
    min-width: 140px;
}

.detail-value {
    font-size: 0.88rem;
    color: var(--text-dark);
    flex: 1;
}

/* ============================================
   LOGIN PAGE
   ============================================ */
.login-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #f5f7fa 0%, #e8f4f4 50%, #f0ebef 100%);
    position: relative;
    overflow: hidden;
}

.login-wrapper::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(58, 166, 166, 0.1) 0%, transparent 70%);
    top: -200px;
    right: -150px;
    border-radius: 50%;
    animation: floatWave 20s ease-in-out infinite;
}

.login-wrapper::after {
    content: '';
    position: absolute;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(108, 74, 99, 0.08) 0%, transparent 70%);
    bottom: -150px;
    left: -100px;
    border-radius: 50%;
    animation: floatWave 24s ease-in-out infinite reverse;
}

.login-card {
    background: var(--white);
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 420px;
    position: relative;
    z-index: 1;
}

.login-card h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-dark);
    text-align: center;
    margin: 0 0 4px 0;
}

.login-card .subtitle {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0 0 24px 0;
}

.logo-container {
    text-align: center;
    margin-bottom: 20px;
}

.logo-container img {
    height: 70px;
    width: auto;
}

/* ============================================
   SEARCH BAR
   ============================================ */
.search-bar {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ============================================
   COLOR UTILITIES
   ============================================ */
.text-turquesa {
    color: var(--turquesa) !important;
}

.text-morado {
    color: var(--morado) !important;
}

.mb-3 {
    margin-bottom: 0.75rem;
}

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

.mb-0 {
    margin-bottom: 0;
}

.mt-2 {
    margin-top: 0.5rem;
}

.mt-3 {
    margin-top: 0.75rem;
}

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

/* ============================================
   ANIMATED WAVY BACKGROUND
   ============================================ */
.bg-waves {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
    background: #f5f7fa;
}

.bg-waves::before,
.bg-waves::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    opacity: 0.07;
    animation: floatWave 20s ease-in-out infinite;
}

.bg-waves::before {
    width: 600px;
    height: 600px;
    background: #3AA6A6;
    top: -200px;
    right: -150px;
}

.bg-waves::after {
    width: 500px;
    height: 500px;
    background: #6C4A63;
    bottom: -150px;
    left: -100px;
    animation-delay: -10s;
}

.wave-decoration {
    position: fixed;
    z-index: -1;
    opacity: 0.04;
    border-radius: 50%;
    animation: floatWave 25s ease-in-out infinite;
}

.wave-decoration.wave-1 {
    width: 400px;
    height: 400px;
    background: #3AA6A6;
    top: 40%;
    left: 60%;
    animation-delay: -5s;
}

.wave-decoration.wave-2 {
    width: 350px;
    height: 350px;
    background: #6C4A63;
    top: 20%;
    left: 20%;
    animation-delay: -15s;
}

@keyframes floatWave {
    0%, 100% { transform: translate(0, 0) rotate(0deg) scale(1); }
    25% { transform: translate(30px, -30px) rotate(5deg) scale(1.05); }
    50% { transform: translate(-20px, 20px) rotate(-3deg) scale(0.95); }
    75% { transform: translate(15px, 10px) rotate(3deg) scale(1.02); }
}

/* ============================================
   FADE-IN ANIMATIONS
   ============================================ */
.animate-fade-in {
    animation: fadeIn 0.5s ease forwards;
    opacity: 0;
}

.animate-delay-1 { animation-delay: 0.1s; }
.animate-delay-2 { animation-delay: 0.2s; }
.animate-delay-3 { animation-delay: 0.3s; }
.animate-delay-4 { animation-delay: 0.4s; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============================================
   GRADIENT BAR HOVER ON CARDS
   ============================================ */
.stat-card-bar::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, #3AA6A6, #6C4A63);
    transform: scaleX(0);
    transition: transform 0.4s ease;
}

.stat-card-bar:hover::after {
    transform: scaleX(1);
}

/* ============================================
   BUTTON SHIMMER EFFECT
   ============================================ */
.btn-shimmer {
    position: relative;
    overflow: hidden;
}

.btn-shimmer::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.btn-shimmer:hover::before {
    left: 100%;
}

/* ============================================
   COLLAPSIBLE SECTIONS
   ============================================ */
.collapse-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease;
}

.collapse-content.open {
    max-height: 2000px;
}

.collapse-toggle .collapse-icon {
    transition: transform 0.3s ease;
}

.collapse-toggle.active .collapse-icon {
    transform: rotate(180deg);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .top-navbar {
        flex-wrap: wrap;
        height: auto;
        padding: 10px 16px;
        gap: 8px;
    }

    .navbar-menu {
        display: none;
    }

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

    .sidebar {
        width: 100%;
        min-width: 100%;
        position: relative;
        top: 0;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding: 12px 16px;
    }

    .sidebar-menu {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
    }

    .page-content {
        padding: 16px;
    }
}

/* ---- Form Controls (replaces Bootstrap) ---- */
.form-control {
    display: block;
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.92rem;
    font-weight: 400;
    line-height: 1.5;
    color: #333;
    background-color: #fff;
    border: 1.5px solid #ddd;
    border-radius: 10px;
    transition: border-color 0.2s, box-shadow 0.2s;
    font-family: inherit;
}

.form-control:focus {
    border-color: #3AA6A6;
    box-shadow: 0 0 0 3px rgba(58, 166, 166, 0.12);
    outline: none;
}

.form-select {
    display: block;
    width: 100%;
    padding: 0.5rem 2rem 0.5rem 0.75rem;
    font-size: 0.92rem;
    font-weight: 400;
    line-height: 1.5;
    color: #333;
    background-color: #fff;
    border: 1.5px solid #ddd;
    border-radius: 10px;
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 16px 12px;
    transition: border-color 0.2s, box-shadow 0.2s;
    font-family: inherit;
}

.form-select:focus {
    border-color: #3AA6A6;
    box-shadow: 0 0 0 3px rgba(58, 166, 166, 0.12);
    outline: none;
}

.form-label {
    display: block;
    margin-bottom: 0.35rem;
    font-weight: 500;
    font-size: 0.88rem;
    color: #444;
}

.input-group {
    display: flex;
    width: 100%;
}

.input-group .form-control {
    border-radius: 0 10px 10px 0;
    flex: 1;
}

.input-group-text {
    display: flex;
    align-items: center;
    padding: 0.5rem 0.75rem;
    font-size: 0.92rem;
    color: #3AA6A6;
    background: var(--bg-light, #f8f9fa);
    border: 1.5px solid #ddd;
    border-right: none;
    border-radius: 10px 0 0 10px;
}

/* ---- Pagination (replaces Bootstrap) ---- */
.pagination {
    display: flex;
    list-style: none;
    padding: 0;
    margin: 0;
    gap: 4px;
}

.page-item .page-link {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border-radius: 10px;
    border: 1.5px solid #ddd;
    background: #fff;
    color: #333;
    font-size: 0.85rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s;
}

.page-item .page-link:hover {
    border-color: #3AA6A6;
    color: #3AA6A6;
}

.page-item.active .page-link {
    background: linear-gradient(135deg, #3AA6A6, #2d8a8a);
    color: #fff;
    border-color: #3AA6A6;
}

.page-item.disabled .page-link {
    opacity: 0.4;
    pointer-events: none;
}

/* ============================================
   FIX DEFINITIVO PARA EXPORTACIÓN PDF
   ============================================ */

@media print {

    /* Desactivar TODAS las animaciones */
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
        transform: none !important;
        opacity: 1 !important;
        filter: none !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* Quitar efectos glass */
    .top-navbar,
    .sidebar {
        backdrop-filter: none !important;
        background: #ffffff !important;
    }

    /* Quitar ondas decorativas */
    .bg-waves,
    .wave-decoration {
        display: none !important;
    }

}