:root {
    --primary: #2472C8; /* Azul más claro de la paleta */
    --primary-hover: #1D5B9E;
    --secondary: #E900D8; /* Magenta de la paleta secundaria */
    --accent: #23B3F3; /* Azul claro de la paleta */
    --bg-color: #FFFFFF; /* Blanco */
    --surface: #F9FAFB; /* Gris casi blanco para las cajas para que no se pierdan en el fondo blanco */
    --text-main: #000000; /* Negro absoluto */
    --text-muted: #333333; /* Gris oscuro de la paleta */
    --border: #D1D5DB;
    --radius: 12px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
}

h1, h2, h3, .logo-area {
    font-family: 'Calistoga', cursive;
}

/* Utils para Vistas SPA */
.view {
    display: none;
    height: 100vh;
    width: 100vw;
}
.view.active {
    display: flex;
}
.sub-view {
    display: none;
}
.sub-view.active {
    display: block;
}

/* --- LOGIN VIEW --- */
.login-container {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--bg-color);
}

.login-box {
    background: var(--surface);
    padding: 3rem;
    border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    width: 100%;
    max-width: 400px;
    animation: slideUp 0.5s ease-out;
}

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

.logo-area {
    text-align: center;
    margin-bottom: 2rem;
}

.logo-area h1 {
    font-size: 2.5rem;
    color: var(--text-main);
    font-weight: 700;
}

.logo-area h1 span {
    color: var(--primary);
}

.logo-area p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

.input-group {
    margin-bottom: 1.5rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
}

.input-group input, 
.input-group select, 
.input-group textarea,
.search-input {
    width: 100%;
    padding: 1rem 1.25rem;
    border: 1px solid #E5E7EB;
    border-radius: 10px;
    font-size: 1rem;
    font-family: inherit;
    background-color: #F9FAFB;
    color: var(--text-main);
    transition: all 0.3s ease;
    box-shadow: inset 0 2px 4px 0 rgba(0, 0, 0, 0.02);
}

.input-group input:focus, 
.input-group select:focus, 
.input-group textarea:focus,
.search-input:focus {
    outline: none;
    border-color: var(--primary);
    background-color: #FFFFFF;
    box-shadow: 0 0 0 4px rgba(36, 114, 200, 0.15);
}

.input-group textarea {
    resize: vertical;
    min-height: 100px;
}

.btn-primary {
    width: 100%;
    padding: 0.875rem;
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

/* --- MAIN VIEW (DASHBOARD) --- */
#main-view {
    display: none; /* hidden by default */
}
#main-view.active {
    display: flex;
}

.sidebar {
    width: 250px;
    background-color: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
    font-size: 1.5rem;
}
.sidebar-header h2 span { color: var(--primary); }

.sidebar-nav {
    padding: 1rem 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.nav-item {
    padding: 0.75rem 1.5rem;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.nav-item:hover, .nav-item.active {
    background-color: rgba(79, 70, 229, 0.05);
    color: var(--primary);
    border-left-color: var(--primary);
}

/* --- AGENDA VIEW --- */
.agenda-container {
    display: flex;
    gap: 2rem;
    height: 100%;
}

.agenda-sidebar {
    width: 250px;
    border-right: 1px solid var(--border);
    padding-right: 1.5rem;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.agenda-main {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.fc-button-primary:not(:disabled):active, 
.fc-button-primary:not(:disabled).fc-button-active {
    background-color: var(--primary) !important;
    color: white !important;
    border-color: var(--primary) !important;
}

/* --- MODAL STYLES --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    width: 100%;
    max-width: 500px;
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 1rem;
}

.btn-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
}

.btn-close:hover {
    color: var(--text-main);
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: 70px;
    background-color: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.btn-secondary {
    padding: 0.5rem 1rem;
    background-color: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background-color: var(--bg-color);
    color: var(--text-main);
}

.content-area {
    padding: 2rem;
    flex: 1;
    overflow-y: auto;
}

.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

/* --- PATIENTS VIEW --- */
.patient-container {
    display: flex;
    gap: 2rem;
    height: 100%;
}

.patient-sidebar {
    width: 300px;
    border-right: 1px solid var(--border);
    padding-right: 1.5rem;
}

.search-input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin: 1rem 0;
    font-family: inherit;
}

.patient-list {
    list-style: none;
    max-height: 500px;
    overflow-y: auto;
}

.patient-item {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.2s;
    border-radius: 8px;
}

.patient-item:hover, .patient-item.active {
    background: rgba(36, 114, 200, 0.05);
    border-left: 3px solid var(--primary);
}

.patient-item strong {
    display: block;
    color: var(--text-main);
}

.patient-item span {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.patient-details {
    flex: 1;
    overflow-y: auto;
    padding-left: 1rem;
}

.details-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.header-actions {
    display: flex;
    gap: 1rem;
}

.btn-whatsapp {
    background-color: #25D366;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
}

.details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.divider {
    border: 0;
    height: 1px;
    background: var(--border);
    margin: 2rem 0;
}

.historia-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-top: 1rem;
}

.historia-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 1rem;
}

.badge {
    background: var(--primary);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.historia-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.seguimiento-item {
    background: rgba(0,0,0,0.02);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.seguimiento-item .fecha {
    font-size: 0.8rem;
    color: var(--primary);
    font-weight: 600;
    display: block;
    margin-bottom: 0.5rem;
}

.evaluacion textarea {
    width: 100%;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    resize: vertical;
}

.btn-text {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    font-weight: 600;
}

/* --- PREMIUM UI ELEMENTS (Avatares, Badges, Tables) --- */
.avatar-circle {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.9rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.badge-status {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}
.badge-status.active {
    background-color: #DEF7EC;
    color: #03543F;
}
.badge-status.inactive {
    background-color: #FDE8E8;
    color: #9B1C1C;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.data-table th, .data-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    background-color: #F9FAFB;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
}

.data-table tbody tr {
    transition: background-color 0.2s;
}

.data-table tbody tr:hover {
    background-color: #F3F4F6;
}

/* --- ADMIN ERP VIEW --- */
.admin-tab {
    padding: 0.75rem 1.5rem;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-muted);
    transition: all 0.2s;
}

.admin-tab:hover {
    color: var(--primary);
}

.admin-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.admin-pane {
    display: none;
    animation: fadeIn 0.3s;
}

.admin-pane.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
