/* ===========================
   ROOT VARIABLES & RESETS
   =========================== */
:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --secondary-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --success-gradient: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --medical-blue: #3b82f6;
    --medical-blue-dark: #1e40af;
    --medical-teal: #14b8a6;
    --medical-purple: #8b5cf6;
    --bg-light: #f8fafc;
    --bg-gradient: linear-gradient(180deg, #f1f5f9 0%, #e2e8f0 100%);
    --card-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    --card-shadow-hover: 0 15px 40px rgba(0, 0, 0, 0.12);
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-radius: 16px;
    --border-radius-sm: 12px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html, body {
    height: 100%;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: white;
    color: var(--text-primary);
    line-height: 1.6;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ===========================
   HEADER STYLES
   =========================== */
.header {
    background: white;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    padding: 1.5rem 0;
    position: sticky;
    top: 0;
    z-index: 1030;
    transition: var(--transition);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 1rem;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.logo-icon {
    font-size: 3.5rem;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}

.logo-text {
    text-align: left;
}

.logo-title {
    font-size: 2rem;
    font-weight: 700;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
    line-height: 1.2;
}

.logo-subtitle {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin: 0.25rem 0 0 0;
    font-weight: 400;
}

/* ===========================
   MAIN CONTENT
   =========================== */
main {
    flex: 1 0 auto;
    padding: 2rem 0 3rem 0;
    min-height: calc(100vh - 250px);
    position: relative;
    z-index: 1;
    overflow: visible;
    background: var(--bg-gradient);
}

.main-container {
    animation: fadeInUp 0.6s ease-out;
    padding-top: 0;
    padding-bottom: 0;
    overflow: visible;
}

.container {
    padding-top: 0;
    padding-bottom: 0;
    overflow: visible;
}

.row {
    margin-top: 0;
    margin-bottom: 0;
}

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

/* ===========================
   NAVIGATION STYLES
   =========================== */
.nav-tabs {
    border: none;
    margin-top: 1rem;
    margin-bottom: 2rem;
    padding: 0 1rem;
    gap: 0.5rem;
    background: transparent;
    display: flex;
    justify-content: center;
}

.nav-tabs .nav-link {
    border: none;
    color: var(--text-secondary);
    font-weight: 500;
    padding: 0.875rem 2rem;
    border-radius: var(--border-radius-sm);
    transition: var(--transition);
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
}

.nav-tabs .nav-link:hover {
    color: var(--medical-blue);
    background: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
}

.nav-tabs .nav-link.active {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.3);
    transform: translateY(-2px);
}

.nav-tabs .nav-link i {
    margin-right: 0.5rem;
}

/* ===========================
   CARD STYLES
   =========================== */
.card {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
    transition: var(--transition);
    background: white;
    overflow: visible !important;
    position: relative;
    z-index: 1;
    margin-bottom: 2rem;
}

.card:hover {
    box-shadow: var(--card-shadow-hover);
    transform: translateY(-4px);
    z-index: 2;
}

.card-header {
    background: var(--primary-gradient);
    color: white;
    padding: 1.5rem;
    font-weight: 600;
    font-size: 1.25rem;
    border: none;
    text-align: center;
}

.card-body {
    padding: 2rem;
}

/* ===========================
   FORM STYLES
   =========================== */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    font-size: 0.95rem;
    line-height: 1.5;
    display: block;
}

.form-text {
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
    line-height: 1.6;
}

.form-control, .form-select {
    border: 2px solid #e2e8f0;
    border-radius: var(--border-radius-sm);
    padding: 0.875rem 1rem;
    font-size: 1rem;
    transition: var(--transition);
    background: white;
}

.form-control:focus, .form-select:focus {
    border-color: var(--medical-blue);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
    outline: none;
}

.form-control::placeholder {
    color: #94a3b8;
    opacity: 1;
    font-style: italic;
    font-weight: 400;
}

.form-control:focus::placeholder {
    color: #cbd5e1;
}

.input-group {
    display: flex;
}

.input-group .form-control {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-right: none;
}

.input-group .form-control:focus {
    z-index: 3;
}

.unit-addon {
    background: #f8fafc;
    color: #64748b;
    border: 2px solid #e2e8f0;
    border-left: none;
    padding: 0.875rem 1rem;
    font-size: 0.95rem;
    font-style: italic;
    font-weight: 500;
    border-top-right-radius: var(--border-radius-sm);
    border-bottom-right-radius: var(--border-radius-sm);
    white-space: nowrap;
    display: flex;
    align-items: center;
}

.input-group:focus-within .unit-addon {
    border-color: var(--medical-blue);
    background: #f1f5f9;
}

.form-control[readonly] {
    background: linear-gradient(135deg, #e0e7ff 0%, #dbeafe 100%);
    border-color: var(--medical-blue);
    font-weight: 600;
    color: var(--medical-blue-dark);
}

.invalid-feedback {
    color: #ef4444;
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

/* Crispy forms specific spacing */
.mb-3 {
    margin-bottom: 2rem !important;
}

div[id^="div_id_"] {
    margin-bottom: 2rem !important;
}

div[id^="div_id_"] label {
    margin-bottom: 0.75rem !important;
    margin-top: 0 !important;
    display: block !important;
}

div[id^="div_id_"] .form-text,
div[id^="div_id_"] small {
    margin-top: 0.75rem !important;
    margin-bottom: 0.5rem !important;
    display: block !important;
    line-height: 1.6 !important;
    color: var(--text-secondary) !important;
}

/* Additional spacing for specific fields */
#div_id_baseline_gfr,
#div_id_sodium_2h,
#div_id_creatinine_2h,
#div_id_user_id {
    margin-bottom: 2rem !important;
}

/* Control label spacing */
.control-label {
    margin-bottom: 0.75rem !important;
    display: block !important;
}

/* Force spacing between label text and helper text */
.control-label + .form-text,
.control-label + small,
label + .form-text,
label + small {
    margin-top: 0.5rem !important;
}

/* Ensure input has space from helper text */
.form-text + .form-control,
.form-text + input,
small + .form-control,
small + input {
    margin-top: 0.75rem !important;
}

/* Generic Bootstrap 5 form spacing overrides */
.mb-3.form-group,
.mb-3 {
    margin-bottom: 2rem !important;
}

/* Space between form elements and their controls */
.form-group > * {
    margin-bottom: 0.5rem;
}

.form-group > *:last-child {
    margin-bottom: 0;
}

/* ===========================
   BUTTON STYLES
   =========================== */
.btn {
    padding: 0.875rem 2rem;
    border-radius: var(--border-radius-sm);
    font-weight: 600;
    transition: var(--transition);
    border: none;
    font-size: 1rem;
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
    opacity: 0.95;
}

.btn-secondary, #reset-btn {
    background: white;
    color: var(--text-primary);
    border: 2px solid #e2e8f0;
}

.btn-secondary:hover, #reset-btn:hover {
    background: #f8fafc;
    border-color: var(--medical-blue);
    color: var(--medical-blue);
    transform: translateY(-2px);
}

.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border: 2px solid #e2e8f0;
}

.btn-outline:hover {
    background: #f8fafc;
    border-color: var(--text-primary);
    color: var(--text-primary);
}

.form-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

/* ===========================
   TABLE STYLES
   =========================== */
.table-responsive {
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--card-shadow);
    background: white;
}

.panel {
    margin-top: 2rem;
}

.panel-primary {
    border: none;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--card-shadow);
}

.panel-heading {
    background: var(--primary-gradient);
    color: white;
    padding: 1.5rem;
    font-weight: 600;
    font-size: 1.25rem;
    text-align: center;
    border: none;
}

.panel-body {
    padding: 1.5rem;
    background: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.table {
    margin-bottom: 0;
    background: white;
}

.table thead th {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-weight: 600;
    padding: 1rem;
    border: none;
    text-align: center;
    vertical-align: middle;
}

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

.table tbody tr:hover {
    background: linear-gradient(90deg, #f8fafc 0%, #f1f5f9 100%);
    transform: scale(1.01);
}

.table tbody td {
    padding: 1rem;
    vertical-align: middle;
    border-color: #e2e8f0;
    text-align: center;
}

.estimated {
    background: linear-gradient(135deg, #dbeafe 0%, #e0e7ff 100%);
    font-weight: 700;
    color: var(--medical-blue-dark);
}

.calculated {
    background: linear-gradient(135deg, #dbeafe 0%, #e0e7ff 100%);
    font-weight: 700;
}

/* ===========================
   PAGINATION STYLES
   =========================== */
.pager {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-top: 2rem;
    padding: 1.5rem;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
}

.pager li a {
    padding: 0.75rem 1.5rem;
    border-radius: var(--border-radius-sm);
    background: white;
    border: 2px solid #e2e8f0;
    color: var(--text-primary);
    text-decoration: none;
    transition: var(--transition);
    font-weight: 500;
}

.pager li a:hover {
    background: var(--primary-gradient);
    color: white;
    border-color: transparent;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.pager li.disabled a {
    opacity: 0.4;
    cursor: not-allowed;
}

.pager li.disabled a:hover {
    background: white;
    color: var(--text-primary);
    transform: none;
    box-shadow: none;
}

.pager-text {
    font-weight: 600;
    color: var(--text-primary);
    padding: 0 1rem;
}

/* ===========================
   PAGE HEADINGS
   =========================== */
.new-data-text {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    position: relative;
}

.new-data-text::after {
    content: '';
    display: block;
    width: 60px;
    height: 4px;
    background: var(--primary-gradient);
    margin: 0.75rem 0 0;
    border-radius: 2px;
}

/* ===========================
   INFO BOX STYLES (About This Calculator)
   =========================== */
.mt-4.p-4.rounded {
    position: relative;
    z-index: 5;
    margin-bottom: 2rem !important;
}

/* ===========================
   FOOTER STYLES
   =========================== */
.footer {
    background: white;
    padding: 2rem 0;
    margin-top: 0;
    border-top: 1px solid #e2e8f0;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.03);
    clear: both;
    width: 100%;
    flex-shrink: 0;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.footer-text p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.footer-text a {
    color: var(--medical-blue);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

.footer-text a:hover {
    color: var(--medical-blue-dark);
    text-decoration: underline;
}

.footer-icon {
    font-size: 2rem;
    color: var(--medical-blue);
    animation: heartbeat 1.5s ease-in-out infinite;
}

@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    10%, 30% { transform: scale(1.1); }
    20%, 40% { transform: scale(1); }
}

/* ===========================
   DROPDOWN STYLES
   =========================== */
.dropdown-toggle {
    background: var(--primary-gradient);
    border: none;
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: var(--border-radius-sm);
    font-weight: 600;
}

.dropdown-toggle:hover {
    opacity: 0.9;
    transform: translateY(-2px);
}

.dropdown-menu {
    border: none;
    border-radius: var(--border-radius-sm);
    box-shadow: var(--card-shadow);
    padding: 0.5rem;
}

.dropdown-menu li a {
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    transition: var(--transition);
    color: var(--text-primary);
}

.dropdown-menu li a:hover {
    background: var(--bg-light);
    color: var(--medical-blue);
}

/* ===========================
   RESPONSIVE DESIGN
   =========================== */
@media (max-width: 768px) {
    .header {
        padding: 1rem 0;
    }

    .logo-section {
        flex-direction: row;
        text-align: left;
        gap: 0.75rem;
        justify-content: center;
    }

    .logo-icon {
        font-size: 2.5rem;
    }

    .logo-text {
        text-align: left;
    }

    .logo-title {
        font-size: 1.5rem;
    }

    .logo-subtitle {
        font-size: 0.85rem;
        margin: 0.15rem 0 0 0;
    }

    /* Add padding to prevent header overlap */
    main {
        padding-top: 1rem;
        margin-top: 0;
    }

    .main-container {
        padding-top: 0;
    }

    .nav-tabs {
        flex-direction: column;
        padding: 0;
        margin-top: 0.5rem;
        margin-bottom: 1.5rem;
    }

    .nav-tabs .nav-link {
        width: 100%;
        text-align: center;
    }

    .form-buttons {
        flex-direction: column;
    }

    .footer-content {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .pager {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .card-body {
        padding: 1.5rem;
    }

    /* Reduce spacing for page headings on mobile */
    .new-data-text {
        font-size: 1.5rem;
    }

    .d-flex.justify-content-between.align-items-center.mb-4 {
        margin-bottom: 1.5rem !important;
        flex-wrap: wrap;
        gap: 1rem;
    }

    .btn-info-toggle {
        width: 100%;
        justify-content: center;
        text-align: center;
    }
}

/* ===========================
   INFO BUTTON STYLES
   =========================== */
.btn-info-toggle {
    min-height: 48px;
    border-radius: 999px;
    border: 2px solid var(--medical-blue);
    background: white;
    color: var(--medical-blue);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 1rem;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.95rem;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
    flex-shrink: 0;
    line-height: 1.2;
    text-align: left;
}

.btn-info-toggle:hover {
    background: var(--primary-gradient);
    color: white;
    border-color: transparent;
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.3);
}

.btn-info-toggle:active {
    transform: translateY(0) scale(0.98);
}

.btn-info-toggle i {
    font-size: 1.35rem;
    line-height: 1;
}

/* ===========================
   MODAL STYLES
   =========================== */
.modal-backdrop {
    z-index: 1040 !important;
}

.modal {
    z-index: 1050 !important;
}

.modal-dialog {
    z-index: 1051 !important;
    position: relative;
}

.modal-content {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    position: relative;
    z-index: 1052 !important;
}

.modal-header {
    padding: 1.5rem;
}

.modal-body {
    padding: 2rem;
    font-size: 1rem;
    line-height: 1.8;
    color: var(--text-primary);
}

.modal-footer {
    padding: 1rem 1.5rem;
}

/* ===========================
   BADGE STYLES
   =========================== */
.badge {
    font-weight: 600;
    letter-spacing: 0.3px;
}

.bg-primary {
    background: var(--primary-gradient) !important;
}

.badge.bg-primary {
    background: var(--primary-gradient) !important;
    border: none;
}

/* ===========================
   ALERT STYLES
   =========================== */
.alert {
    border-radius: var(--border-radius-sm);
}

.alert-info {
    background: linear-gradient(135deg, #dbeafe 0%, #e0e7ff 100%);
    color: var(--text-primary);
}

/* ===========================
   INFO GROUP STYLES
   =========================== */
.info-group {
    transition: var(--transition);
}

.info-group:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* ===========================
   RESULT HIGHLIGHT
   =========================== */
.result-highlight {
    animation: resultPulse 2s ease-in-out infinite;
}

@keyframes resultPulse {
    0%, 100% {
        box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
    }
    50% {
        box-shadow: 0 12px 35px rgba(102, 126, 234, 0.4);
    }
}

/* ===========================
   UTILITY CLASSES
   =========================== */
.bg-primary:hover:not(thead) {
    background: linear-gradient(90deg, #dbeafe 0%, #e0e7ff 100%);
}

.text-gradient {
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

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

/* ===========================
   SMOOTH SCROLLING
   =========================== */
html {
    scroll-behavior: smooth;
}

/* ===========================
   SELECTION STYLES
   =========================== */
::selection {
    background: var(--medical-blue);
    color: white;
}

::-moz-selection {
    background: var(--medical-blue);
    color: white;
}
