@import url('https://fonts.googleapis.com/css2?family=Noto+Sans:wght@400;600;700;800&display=swap');
:root { --brand-start:#6a11cb; --brand-end:#2575fc; --brand:#4A47A3; --surface:#fff; --bg:#f5f7fb; --brand-start-weak:#6a11cb26; --brand-end-weak:#2575fc26; }

body {
    font-family: 'Noto Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.6;
    background-color: var(--bg);
    color: #333;
    padding: 0;
    margin: 0;
}

/* --- LOGIN PAGE STYLES --- */
.login-wrapper {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

.brand-section {
    flex: 1;
    background-color: #f0f2f5;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 40px;
    text-align: center;
}

.brand-title {
    font-size: 150px;
    font-weight: 800;
    margin: 0;
    letter-spacing: -2px;
    background: linear-gradient(90deg, var(--brand-start) 0%, var(--brand-end) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    color: transparent;
}

.brand-subtitle {
    margin-top: 10px;
    color: #6c757d;
    font-size: 18px;
    max-width: 400px;
}

.login-section {
    flex: 1;
    background-color: #f0f2f5; /* Same as brand for consistency */
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
}

.login-box {
    background-color: var(--surface);
    padding: 50px 40px;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    width: 100%;
    max-width: 420px;
    text-align: left;
}

.login-form-title {
    font-size: 28px;
    font-weight: 700;
    color: #333;
    margin-top: 0;
    margin-bottom: 30px;
    text-align: left;
}

.login-form-group {
    margin-bottom: 25px;
    text-align: left;
}

.login-form-group label {
    display: block;
    font-weight: 600;
    color: #555;
    margin-bottom: 8px;
    font-size: 14px;
}

.login-form-group label svg {
    color: #888;
}

.login-form-group input {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-sizing: border-box;
    font-size: 16px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.login-form-group input:focus {
    outline: none;
    border-color: var(--brand-start);
    box-shadow: 0 0 0 3px rgba(106, 17, 203, 0.15);
}

#login-button {
    width: 100%;
    padding: 15px 20px;
    border: none;
    border-radius: 8px;
    color: white;
    background: linear-gradient(90deg, var(--brand-start) 0%, var(--brand-end) 100%);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    margin-top: 10px;
}

#login-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(106, 17, 203, 0.3);
}

#login-response-message {
    margin-top: 20px;
    padding: 12px;
    border-radius: 6px;
    font-weight: 500;
    display: none; /* Hidden by default */
}

#login-form #username {
    text-transform: uppercase;
}

/* --- Header --- */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    margin-bottom: 20px;
}

#welcome-message {
    font-size: 16px;
    font-weight: 500;
    color: #333;
}

#welcome-message span {
    font-weight: 700;
    color: var(--brand); /* A nice purple from the login page */
}

#logout-button {
    background-color: #f44336;
    color: white;
    padding: 8px 15px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: background-color 0.2s;
}

#logout-button:hover {
    background-color: #d32f2f;
}

/* --- MANAGEMENT PAGE STYLES --- */
body:not(.login-container) {
    max-width: 1400px;
    margin: 0 auto;
}

h1 {
    color: var(--brand); /* Supabase green */
    text-align: center;
    margin-bottom: 20px;
}

h2 {
    color: #333;
    border-bottom: 2px solid #eee;
    padding-bottom: 10px;
    margin-top: 0;
}

h3 {
    color: #333;
    border-bottom: 1px solid #eee;
    padding-bottom: 8px;
    margin-top: 0;
}

nav {
    margin-bottom: 20px;
    background-color: #fff;
    padding: 10px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

nav a {
    text-decoration: none;
    color: var(--brand);
    padding: 8px 15px;
    border-radius: 4px;
    margin-right: 10px;
    font-weight: 500;
    transition: background-color 0.2s, color 0.2s;
}

nav a:hover {
    background-color: #e6f6ec;
}

nav a.active {
    background-color: var(--brand);
    color: white;
}

.top-section {
    grid-column: 1 / -1;
    margin-bottom: 20px;
}

.antecedentes-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.main-content-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.left-column, .right-column, .antecedentes-column {
    display: flex;
    flex-direction: column;
   /* gap: 20px;*/
}

.antecedentes-column {
    gap: 20px;
}

.form-section, .antecedentes-section {
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
}

/* Add new form styles */
form {
    margin-top: 10px;
    padding: 0;
    background-color: transparent;
    border: none;
    box-shadow: none;
}

.form-group {
    margin-bottom: 15px;
    position: relative; /* Added for suggestion box positioning */
}

form label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #555;
}

form input[type="text"],
form input[type="date"],
form input[type="tel"],
form input[type="password"],
form select,
form textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box; /* Ensures padding doesn't affect overall width */
    font-size: 16px;
    font-family: inherit; /* Ensure textarea uses the same font */
}

form input:read-only {
    background-color: #eee;
    cursor: default;
}

/* Convertir texto a mayúsculas en los inputs de texto de los formularios */
form input[type="text"] {
    text-transform: uppercase;
}

/* Forzar la capitalización correcta en el campo de rol */
form input[name="role_name"],
form input[name="role_name_users"] {
    text-transform: capitalize;
}

form small {
    display: block;
    margin-top: 5px;
    color: #777;
    font-size: 0.8em;
}

form button {
    background-color: #36ad69; /* Supabase green */
    color: white;
    padding: 12px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    width: 100%;
    transition: background-color 0.2s;
}

form button:hover {
    background-color: #2b8a55;
}

form button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

#response-message-main, #response-message-antepafa, #response-message-antepaper, #response-message-users {
    margin-top: 20px;
    padding: 15px;
    border-radius: 4px;
    font-weight: bold;
    display: none; /* Hidden by default */
}

.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    display: block;
}

.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    display: block;
}

/* Stats Cards */
.stat-card {
    background: linear-gradient(135deg, var(--brand-start-weak), var(--brand-end-weak));
    border: 1px solid rgba(74, 71, 163, 0.2);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

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

.stat-icon {
    margin-bottom: 10px;
}

.stat-label {
    font-size: 14px;
    color: #666;
    font-weight: 500;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: #333;
}

.chart-container {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.chart-container h3 {
    margin-top: 0;
    font-size: 16px;
    color: #333;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

.chart-container canvas {
    max-height: 250px;
}

/* Styles for the antecedents list */
.antecedentes-container {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #ddd;
}

.antecedentes-container h3, .antecedentes-container h4 {
    margin-top: 0;
    color: #333;
}

#antecedentes-familiares-list, #antecedentes-personales-list, #telefonos-list {
    list-style-type: none;
    padding: 0;
}

#antecedentes-familiares-list li, #antecedentes-personales-list li, #telefonos-list li {
    padding: 10px;
    border-bottom: 1px solid #eee;
}

#antecedentes-familiares-list li:last-child, #antecedentes-personales-list li:last-child, #telefonos-list li:last-child {
    border-bottom: none;
}

#antecedentes-familiares-list li strong, #antecedentes-personales-list li strong, #telefonos-list li strong {
    color: #36ad69;
}

/* --- Table Styles for Admin User List --- */
.table-container {
    width: 100%;
    overflow-x: auto; /* For responsive behavior on small screens */
}

#users-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

#users-table th, #users-table td {
    padding: 12px 15px;
    border: 1px solid #ddd;
    text-align: left;
    font-size: 14px;
}

#users-table th {
    background-color: #f4f4f4;
    font-weight: 600;
    color: #333;
}

#users-table tbody tr:nth-child(even) {
    background-color: #f9f9f9;
}

#users-table tbody tr:hover {
    background-color: #f1f1f1;
}

/* --- Autocomplete Suggestions --- */
.suggestions-container {
    display: none;
    position: absolute;
    border: 1px solid #ddd;
    border-top: none;
    background-color: white;
    z-index: 1000;
    width: calc(100% - 44px); /* Adjust based on form padding */
    max-height: 200px;
    overflow-y: auto;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    border-radius: 0 0 4px 4px;
}

.suggestion-item {
    padding: 10px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover {
    background-color: #f0f2f5;
}

.whatsapp-search-container {
    margin-top: 30px;
    margin-bottom: 30px;
}

/* --- ADMIN DASHBOARD STYLES --- */
.search-section {
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    margin-bottom: 20px;
}

#search-button {
    background-color: var(--brand); /* A nice purple from the login page */
    color: white;
    padding: 12px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    width: 100%;
    transition: background-color 0.2s;
}

#search-button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

#search-button:hover:not(:disabled) {
    background-color: #3b3882;
}

.results-container {
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    margin-top: 0; /* Adjusted from 20px to align better in a single column layout */
}

.results-container h2 {
    color: #333;
    font-size: 24px;
    margin-top: 0;
    margin-bottom: 20px;
    border-bottom: 2px solid #eee;
    padding-bottom: 10px;
}

.results-container h3 {
    color: var(--brand);
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 8px;
    margin-top: 25px;
    margin-bottom: 15px;
    font-size: 18px;
}

.results-container h3:first-of-type {
    margin-top: 0;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.result-item {
    font-size: 14px;
    background-color: #f9f9f9;
    padding: 10px;
    border-radius: 4px;
    border-left: 3px solid var(--brand);
}

.result-item strong {
    display: block;
    color: #555;
    font-weight: 600;
    margin-bottom: 4px;
    font-size: 12px;
    text-transform: uppercase;
}

.result-item span {
    color: #333;
    font-weight: 500;
}

.result-list {
    list-style-type: none;
    padding: 0;
}

.result-list li {
    padding: 12px;
    border-bottom: 1px solid #f0f0f0;
    line-height: 1.5;
}

.result-list li:last-child {
    border-bottom: none;
}

.result-list li strong {
    color: #333;
    min-width: 120px;
    display: inline-block;
}

/* --- DOCTOR HISTORY PAGE STYLES --- */
.patient-info-header {
    background-color: #f9f9f9;
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 20px;
    border-left: 3px solid var(--brand-start);
}

.patient-info-header h3 {
    margin: 0 0 5px 0;
    color: #333;
}

.patient-info-header p {
    margin: 0;
    color: #555;
}

#historial-list {
    max-height: 60vh;
    overflow-y: auto;
    padding-right: 10px; /* space for scrollbar */
}

.historial-entry {
    background-color: #fdfdff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    margin-bottom: 15px;
    padding: 15px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.historial-header {
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
    margin-bottom: 10px;
    font-size: 0.9em;
    color: #666;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
}

.historial-body h4 {
    margin: 15px 0 5px 0;
    color: var(--brand);
    font-size: 1em;
}

.historial-body h4:first-child {
    margin-top: 0;
}

.historial-body p {
    margin: 0 0 10px 0;
    line-height: 1.6;
    color: #333;
    white-space: pre-wrap; /* Preserve line breaks from textarea */
}

/* --- Tweak for single-column indication list --- */
#historial-list .historial-body {
    display: block; /* Override grid display */
}

/* --- Improved History Details Layout --- */
.historial-body {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 20px;
    padding-top: 15px;
}

.historial-section {
    background-color: #fcfdff;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #e9e9e9;
    box-shadow: 0 2px 5px rgba(0,0,0,0.03);
}

.historial-section h4 {
    margin-top: 0;
    font-size: 1.1em;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
    margin-bottom: 15px;
    color: var(--brand);
}

.historial-section p, .historial-section ul {
    font-size: 0.95em;
    line-height: 1.6;
    color: #333;
}

.historial-section p {
    white-space: pre-wrap; /* Preserve line breaks */
}

.historial-section ul {
    margin: 0;
}

/* --- TABS --- */
.tabs-container {
    width: 100%;
}

.tab-nav {
    display: flex;
    border-bottom: 1px solid #ccc;
    margin-bottom: 20px;
}

.tab-button {
    padding: 10px 20px;
    cursor: pointer;
    border: none;
    background-color: transparent;
    border-bottom: 3px solid transparent;
    font-size: 16px;
    font-weight: 500;
    color: #555;
    transition: all 0.2s ease-in-out;
}

.tab-button:hover {
    background-color: #f0f2f5;
    color: #333;
}

.tab-button.active {
    border-bottom: 3px solid var(--brand-start);
    color: #333;
    font-weight: 600;
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

/* --- NEW STYLES for History Page Layout --- */
.history-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 20px;
    margin-top: 20px;
}

.date-list-column {
    border-right: 1px solid #e0e0e0;
    padding-right: 20px;
    max-height: 70vh;
    overflow-y: auto;
}

.date-list-column h4 {
    margin-top: 0;
    color: #333;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

.date-list {
    list-style-type: none;
    padding: 0;
    margin: 0;
}

.date-list li {
    margin-bottom: 8px;
}

.date-list button {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: #f9f9f9;
    cursor: pointer;
    text-align: left;
    transition: background-color 0.2s, border-color 0.2s;
    display: flex;
    flex-direction: column;
}

.date-list button:hover {
    background-color: #f0f2f5;
    border-color: #ccc;
}

.date-list button.active {
    background-color: var(--brand);
    color: white;
    border-color: #3b3882;
    font-weight: bold;
}

.date-list button .date {
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

.date-list button .time {
    font-weight: 400;
    color: #666;
    font-size: 0.9em;
}

.date-list button .doctor {
    font-size: 12px;
    color: #555;
    margin-top: 4px;
}

.history-details-column p:first-child {
    margin-top: 0;
    color: #777;
    font-style: italic;
}

#dashboard-results .error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    padding: 15px;
    border-radius: 4px;
}

.vital-signs-list {
    list-style-type: none;
    padding-left: 0;
    font-size: 0.9em;
}

.vital-signs-list li, .recetas-list li {
    padding: 4px 0;
    border-bottom: 1px solid #f0f0f0;
}

.vital-signs-list li:last-child, .recetas-list li:last-child {
    border-bottom: none;
}

.recetas-list {
    list-style-type: disc;
    padding-left: 20px;
    font-size: 0.9em;
}

/* Add styles for new indications list */
.indicaciones-list {
    list-style-type: decimal;
    padding-left: 20px;
    font-size: 0.9em;
}

.indicaciones-list li {
    padding: 4px 0;
    border-bottom: 1px solid #f0f0f0;
}

.indicaciones-grid {
    display: block; /* Change from grid to block to contain the single list */
}

.indicaciones-grid .indicaciones-list {
    column-count: 2;
    column-gap: 20px;
}

.indicaciones-list li:last-child {
     border-bottom: none;
}

/* --- VITAL SIGNS & RECETAS FORM STYLES --- */
.sub-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
    margin-bottom: 20px;
}

.vital-signs-section, .recetas-section, .indicaciones-section {
    padding: 15px;
    margin: 0;
    box-shadow: none;
    border: 1px solid #eee;
    border-radius: 6px;
    background-color: #fcfcfc;
    display: flex;
    flex-direction: column;
}

.vital-sign-row {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
}

.vital-sign-row .vital-sign-signo {
    flex: 2;
}

.vital-sign-row .vital-sign-valor {
    flex: 1;
}

.receta-row {
    display: flex;
    gap: 10px;
    align-items: flex-start; /* Align to top for textarea */
    margin-bottom: 10px;
}

.indicacion-row {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    margin-bottom: 10px;
}

.receta-row textarea, .indicacion-row textarea {
    flex: 1;
    min-height: 80px;
}

.remove-vital-sign-button, .remove-receta-button, .remove-indicacion-button {
    background: transparent;
    border: 1px solid #ddd;
    color: #f44336;
    padding: 8px;
    height: 40px;
    width: 40px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s, color 0.2s;
    flex-shrink: 0; /* Prevent button from shrinking */
}

.remove-vital-sign-button:hover, .remove-receta-button:hover, .remove-indicacion-button:hover {
    background-color: #f8d7da;
    color: #721c24;
}

.secondary-button {
    background-color: #fff;
    color: var(--brand);
    border-color: var(--brand);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.secondary-button:hover {
    background-color: rgba(74, 71, 163, 0.08);
    color: var(--brand);
    border-color: var(--brand);
}

/* --- REPORT STYLES --- */
.report-body {
    background-color: #ccc;
}

.report-controls {
    display: flex;
    gap: 20px;
    justify-content: center;
    padding: 20px;
    background-color: #fff;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    margin-bottom: 20px;
    border-radius: 8px;
    max-width: 1000px;
    margin-left: auto;
    margin-right: auto;
}

.report-controls button, .report-controls a {
    padding: 10px 20px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
    transition: background-color 0.2s;
}

#print-button {
    background-color: #36ad69;
    color: white;
}

#print-button:hover {
    background-color: #2b8a55;
}

.report-controls a {
    background-color: var(--bg);
    color: #333;
    border: 1px solid #ddd;
}

.report-controls a:hover {
     background-color: #e6e8eb;
}

#report-container {
    display: flex;
    justify-content: center;
    gap: 20px;
    padding: 20px;
}

.report-page {
    background-color: #fff;
    width: 210mm;
    height: 297mm; /* A4 height */
    padding: 15px;
    box-sizing: border-box;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    font-family: Arial, sans-serif;
    color: #000;
    display: flex;
    flex-direction: column;
}

.report-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 1px solid #000;
    padding-bottom: 5px;
}

.logo-inmedia {
    width: 90px;
    height: auto;
}

.logo-medical {
    width: 60px;
    height: auto;
    margin-top: 5px;
}

.header-text {
    text-align: center;
    font-size: 12px;
    line-height: 1.2;
}

.header-text h2 {
    font-size: 24px;
    margin: 0;
    padding: 0;
    border: none;
}

.header-text .subtitle {
    font-size: 12px;
    font-weight: bold;
    margin: 0;
}

.header-text p {
    margin: 1px 0;
}

.doctor-name { font-weight: bold; }

.report-date {
    text-align: right;
    font-size: 12px;
    margin: 10px 0;
}

.patient-name {
    font-size: 12px;
    font-weight: bold;
    border: 1px solid #000;
    padding: 5px;
    margin: 0 auto 10px auto;
    line-height: 1.5;
    display: table;
    text-align: center;
}

.report-content {
    flex-grow: 1;
    font-size: 12px;
    display: flex;
    gap: 20px;
}

.report-content-full {
    flex-grow: 1;
    font-size: 12px;
}

.report-content h3 {
    font-size: 14px;
    text-decoration: underline;
    text-align: center;
    margin-bottom: 10px;
    padding-bottom: 0;
    border-bottom: none;
}

.report-column {
    flex: 1;
}

.report-column:first-child {
    flex: 1;
}

.report-column:last-child {
    flex: 2;
}

.report-content ol {
    padding-left: 20px;
    margin: 0;
    font-size: 10px;
}

.report-content li {
    margin-bottom: 4px;
    line-height: 1.2;
}

.report-footer {
    border-top: 1px solid #000;
    padding-top: 5px;
    text-align: center;
    font-size: 9px;
}

.report-footer p {
    margin: 1px 0;
}

.report-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    font-size: 11px;
}
.report-table th, .report-table td {
    border: 1px solid #000;
    padding: 4px;
    text-align: left;
    vertical-align: top;
}
.report-table th {
    background-color: #f0f0f0;
}

/* --- Change Password Page --- */
.change-password-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.change-password-box {
    background-color: #ffffff;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 450px;
}

.change-password-box h2 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 10px;
    color: #333;
    border-bottom: none;
}

.change-password-box p {
    margin-bottom: 25px;
    color: #666;
    font-size: 15px;
}

/* --- Agendar Cita Page --- */
.cita-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 15px;
}

#time-slots-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: #f9f9f9;
    min-height: 60px;
}

#time-slots-container p {
    margin: auto;
    color: #777;
}

.time-slot-button {
    padding: 10px 15px;
    border: 1px solid #a9dfbf; /* Light green border */
    border-radius: 4px;
    background-color: #e8f8f5; /* Very light green background */
    color: #1e8449; /* Darker green text */
    cursor: pointer;
    font-weight: 600; /* Bolder text */
    font-size: 15px; /* Slightly larger font */
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.time-slot-button:hover {
    background-color: #d1f2eb;
    border-color: #58d68d;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.time-slot-button.active {
    background-color: #36ad69;
    color: white;
    border-color: #2b8a55;
    font-weight: bold;
}

#citas-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

#citas-table th, #citas-table td {
    padding: 12px 15px;
    border: 1px solid #ddd;
    text-align: left;
    font-size: 14px;
}

#citas-table th {
    background-color: #f4f4f4;
}

#citas-table .status-agendada {
    background-color: #e0f7fa;
    color: #006064;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: bold;
}

#citas-table .status-completada {
    background-color: #dcedc8;
    color: #33691e;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: bold;
}

#citas-table .status-cancelada {
    background-color: #ffcdd2;
    color: #b71c1c;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: bold;
}

#citas-table .status-en_atencion {
    background-color: #fff3cd;
    color: #856404;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: bold;
}

#citas-table .status-atendido {
    background-color: #d4edda;
    color: #155724;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: bold;
}

.cita-action-btn {
    border: 1px solid var(--brand);
    background-color: #fff;
    color: var(--brand);
    font-weight: 600;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

.form-inline-row { display: flex; gap: 16px; align-items: flex-end; }

#submit-historia-button {
    background: linear-gradient(90deg, var(--brand-start) 0%, var(--brand-end) 100%);
}

#submit-examen-button,
#submit-tratamiento-button,
#submit-pendiente-button,
#submit-plan-button {
    background: linear-gradient(90deg, var(--brand-start) 0%, var(--brand-end) 100%);
}

#submit-cita-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: linear-gradient(90deg, #4A5EFF 0%, #9B55FF 100%);
    color: white;
    padding: 16px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    width: 100%;
    transition: transform 0.2s, box-shadow 0.2s;
}

#submit-cita-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(74, 94, 255, 0.4);
}

#submit-cita-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

#submit-cita-button svg {
    flex-shrink: 0;
}

.exam-row input[type="text"] {
    font-size: 10px;
    padding: 5px 8px;
    min-height: 20px;
    height: 30px;
}

.exam-row textarea.examen-search {
    font-size: 10px;
    padding: 5px 8px;
    min-height: 40px;
    height: auto;
    resize: none;
    overflow-wrap: break-word;
    word-wrap: break-word;
    white-space: normal;
    line-height: 1.3;
}

@media print {
    body, .report-body {
        background-color: #fff;
        padding: 0;
        margin: 0;
    }
    .report-controls {
        display: none;
    }
    #report-container {
        padding: 0;
        gap: 0;
        display: block; /* Each page will stack for printing */
    }
    .report-page {
        box-shadow: none;
        margin: 0;
        width: 100%;
        height: auto; /* Let content determine height */
        page-break-after: avoid;
    }
    .report-page:last-child {
        page-break-after: auto;
    }
}

@media (max-width: 900px) {
    .login-wrapper { flex-direction: column; }
    .brand-title { font-size: 64px; letter-spacing: -1px; }
    .brand-subtitle { font-size: 16px; }
    .antecedentes-grid {
        grid-template-columns: 1fr;
    }
    .main-content-grid {
        grid-template-columns: 1fr;
    }
    .history-layout {
        grid-template-columns: 1fr; /* Stack columns on smaller screens */
    }
    .date-list-column {
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
        padding-right: 0;
        padding-bottom: 20px;
        margin-bottom: 20px;
        max-height: 40vh;
    }
}

.left-column {
    display: flex;
    flex-direction: column;
    /*gap: 20px;*/
}

.phone-input-group {
    display: flex;
    gap: 5px;
    align-items: center;
}

.phone-input-group select {
    width: auto;
    flex-shrink: 0;
}

.phone-input-group input {
    flex-grow: 1;
}

.password-container {
    position: relative;
}

.password-container input {
    padding-right: 40px; /* Make space for the icon */
}

.toggle-password-icon {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    user-select: none; /* prevent text selection */
    color: #777;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toggle-password-icon:hover {
    color: #333;
}

form textarea {
    text-transform: uppercase;
}

#examenes-list-container .historial-section {
    background-image: linear-gradient(90deg, var(--brand-start-weak), var(--brand-end-weak));
    border-color: rgba(74, 71, 163, 0.25);
}

#tratamientos-anteriores-list .historial-section,
#pendientes-list-container .historial-section,
#planes-list-container .historial-section {
    background-image: linear-gradient(90deg, var(--brand-start-weak), var(--brand-end-weak));
    border-color: rgba(74, 71, 163, 0.25);
}

.print-meta {
    font-size: 8px;
    color: #555;
    text-align: right;
    margin-bottom: 4px;
}

body.recepcionista form button { background: linear-gradient(90deg, var(--brand-start) 0%, var(--brand-end) 100%); }
body.recepcionista .secondary-button, body.recepcionista .cita-action-btn { color: var(--brand); border-color: var(--brand); }
body.recepcionista .time-slot-button { border-color: var(--brand); background-color: var(--brand-start-weak); color: #000; }
body.recepcionista .time-slot-button.active { background-color: var(--brand); color: #fff; border-color: var(--brand-end); }