/* Portal Web Dentactil - Estilos */

/* === Variables === */
:root {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-900: #111827;
}

/* === Reset y base === */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: var(--gray-900);
    background: var(--gray-50);
}

/* === Navegación === */
.navbar {
    background: white;
    border-bottom: 1px solid var(--gray-200);
    padding: 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-brand h1 {
    font-size: 1.5rem;
    color: var(--primary);
}

.clinic-name {
    color: var(--gray-600);
    font-size: 0.9rem;
}

.nav-menu {
    display: flex;
    gap: 0.5rem;
    list-style: none;
}

.nav-menu a {
    color: var(--gray-700);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    transition: background 0.2s;
}

.nav-menu a:hover {
    background: var(--gray-100);
}

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

.nav-menu a.logout {
    color: var(--error);
}

/* === Contenido principal === */
.main-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
    min-height: calc(100vh - 140px);
}

/* === Headers === */
.page-header {
    margin-bottom: 2rem;
}

.page-header h2 {
    font-size: 2rem;
    color: var(--gray-900);
    margin-bottom: 0.25rem;
}

.subtitle {
    color: var(--gray-600);
    font-size: 0.9rem;
}

.header-with-back {
    display: flex;
    gap: 1rem;
    align-items: center;
}

/* === Flash Messages === */
.flash-messages {
    margin-bottom: 2rem;
}

.flash {
    padding: 1rem 1.5rem;
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.flash-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid var(--success);
}

.flash-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid var(--error);
}

.flash-warning {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid var(--warning);
}

.flash-info {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid var(--primary);
}

.flash-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    opacity: 0.6;
}

.flash-close:hover {
    opacity: 1;
}

/* === Cards === */
.card {
    background: white;
    border-radius: 0.5rem;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* === Dashboard === */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.card-status {
    grid-column: 1 / -1;
}

.card-metric {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.metric-icon {
    font-size: 3rem;
}

.metric-content h3 {
    font-size: 0.9rem;
    color: var(--gray-600);
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.metric-value {
    font-size: 2rem;
    font-weight: bold;
    color: var(--gray-900);
    margin-bottom: 0.5rem;
}

.card-link {
    color: var(--primary);
    text-decoration: none;
    font-size: 0.9rem;
}

.card-link:hover {
    text-decoration: underline;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.25rem;
    font-weight: 600;
    margin: 1rem 0;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.status-online .status-dot {
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
}

.status-offline .status-dot {
    background: var(--error);
    box-shadow: 0 0 8px var(--error);
}

/* === Tablas === */
.table-container {
    background: white;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead {
    background: var(--gray-50);
}

.data-table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--gray-700);
    border-bottom: 2px solid var(--gray-200);
    transition: background 0.2s;
}

/* Cabeceras ordenables */
.data-table th.sortable {
    position: relative;
    padding-right: 2rem;
}

.data-table th.sortable:hover {
    background: #f0f4ff;
}

.data-table th .sort-icon {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.data-table th.sortable:hover .sort-icon {
    color: var(--primary);
}

.data-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--gray-200);
}

.data-table tbody tr:hover {
    background: var(--gray-50);
}

.nowrap {
    white-space: nowrap;
}

.text-small {
    font-size: 0.85rem;
    color: var(--gray-600);
}

/* === Badges === */
.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-confirmada,
.badge-confirmed {
    background: #d1fae5;
    color: #065f46;
}

.badge-pendiente,
.badge-pending {
    background: #fef3c7;
    color: #92400e;
}

.badge-cancelada,
.badge-cancelled {
    background: #fee2e2;
    color: #991b1b;
}

.badge-completed,
.badge-completado {
    background: #d1fae5;
    color: #065f46;
}

.badge-processing,
.badge-procesando {
    background: #dbeafe;
    color: #1e40af;
}

.badge-failed,
.badge-fallido,
.badge-error {
    background: #fee2e2;
    color: #991b1b;
}

.badge-sync,
.badge-full_sync,
.badge-incremental_sync {
    background: #e0e7ff;
    color: #3730a3;
}

.badge-patient,
.badge-paciente,
.badge-appointment,
.badge-cita {
    background: #f3e8ff;
    color: #6b21a8;
}

.badge-created {
    background: #d1fae5;
    color: #065f46;
}

.badge-modified,
.badge-updated {
    background: #fef3c7;
    color: #92400e;
}

.badge-info {
    background: #dbeafe;
    color: #1e40af;
}

.badge-success {
    background: #d1fae5;
    color: #065f46;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.text-center {
    text-align: center;
}

/* === Botones === */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    text-decoration: none;
    border: 1px solid var(--gray-300);
    background: white;
    color: var(--gray-700);
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.btn:hover {
    background: var(--gray-50);
    border-color: var(--gray-400);
}

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

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

.btn-sm {
    padding: 0.25rem 0.75rem;
    font-size: 0.85rem;
}

.btn-block {
    display: block;
    width: 100%;
    text-align: center;
}

.btn-back {
    background: var(--gray-100);
}

/* === Paginación === */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-top: 2rem;
}

.pagination-info {
    color: var(--gray-600);
    font-size: 0.9rem;
}

/* === Estados vacíos === */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--gray-600);
}

.empty-state p:first-child {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

/* === Detalle === */
.detail-container {
    display: grid;
    gap: 1.5rem;
}

.detail-card {
    background: white;
    border-radius: 0.5rem;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.detail-card h3 {
    margin-bottom: 1rem;
    color: var(--gray-900);
    border-bottom: 2px solid var(--gray-200);
    padding-bottom: 0.5rem;
}

.detail-list {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 0.75rem;
}

.detail-list dt {
    font-weight: 600;
    color: var(--gray-700);
}

.detail-list dd {
    color: var(--gray-900);
}

.json-display {
    background: var(--gray-50);
    padding: 1rem;
    border-radius: 0.375rem;
    overflow-x: auto;
    font-size: 0.85rem;
}

.simple-list {
    list-style: none;
}

.simple-list li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--gray-200);
}

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

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-top: 1rem;
}

.stat-item {
    padding: 1rem;
    background: var(--gray-50);
    border-radius: 0.375rem;
}

.stat-item strong {
    display: block;
    margin-bottom: 0.75rem;
    color: var(--gray-700);
}

.stat-item .simple-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
}

/* === Login === */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary) 0%, #1e40af 100%);
}

.login-box {
    background: white;
    border-radius: 0.5rem;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 400px;
    padding: 2rem;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header h1 {
    font-size: 2.5rem;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.login-header h2 {
    font-size: 1.25rem;
    color: var(--gray-700);
    font-weight: 500;
}

.login-form {
    margin-bottom: 1.5rem;
}

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

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--gray-700);
}

.form-group input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--gray-300);
    border-radius: 0.375rem;
    font-size: 1rem;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group select,
.form-select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--gray-300);
    border-radius: 0.375rem;
    font-size: 1rem;
    background: white;
    cursor: pointer;
}

.form-group select:focus,
.form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.login-footer {
    text-align: center;
    color: var(--gray-600);
    font-size: 0.85rem;
}

/* === Alerts === */
.alert {
    padding: 1rem 1.5rem;
    border-radius: 0.5rem;
    margin-top: 2rem;
}

.alert-warning {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid var(--warning);
}

.info-box {
    background: #dbeafe;
    border: 1px solid var(--primary);
    border-radius: 0.5rem;
    padding: 1rem;
    margin-top: 2rem;
}

/* === Footer === */
.footer {
    background: white;
    border-top: 1px solid var(--gray-200);
    text-align: center;
    padding: 1.5rem;
    color: var(--gray-600);
    font-size: 0.85rem;
}

/* === Utilidades === */
.muted {
    color: var(--gray-600);
    font-size: 0.9rem;
}

.error {
    color: var(--error);
}

.error-detail {
    font-size: 0.85rem;
    margin-top: 0.5rem;
}

/* === Cajas de mensajes === */
.message-box {
    padding: 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    border-left: 4px solid;
}

.message-info {
    background: #dbeafe;
    border-color: var(--primary);
}

.message-error {
    background: #fee2e2;
    border-color: var(--error);
}

.message-box strong {
    display: block;
    margin-bottom: 0.5rem;
}

.message-box p {
    margin: 0;
}

/* === Payload display === */
.payload-summary {
    font-size: 0.85rem;
    line-height: 1.4;
}

.payload-summary strong {
    color: var(--gray-700);
}

.event-summary .event-header {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
}

.event-type-badge {
    flex-shrink: 0;
}

.event-meta {
    flex: 1;
}

.event-meta p {
    margin: 0.5rem 0;
}

.payload-highlight {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border: 2px solid var(--primary);
}

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

.payload-item {
    background: white;
    padding: 0.75rem;
    border-radius: 0.375rem;
    border-left: 3px solid var(--primary);
}

.payload-label {
    display: block;
    font-size: 0.75rem;
    color: var(--gray-600);
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 0.25rem;
}

.payload-value {
    display: block;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--gray-900);
}

details summary {
    cursor: pointer;
    user-select: none;
}

details[open] summary {
    margin-bottom: 0.5rem;
}

/* === Dashboard KPIs === */
.time-filters {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 2rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.filter-label {
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--gray-700);
}

.filter-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.filter-btn {
    padding: 0.5rem 1rem;
    border-radius: 6px;
    background: var(--gray-100);
    color: var(--gray-700);
    text-decoration: none;
    border: 2px solid transparent;
    transition: all 0.2s;
    cursor: pointer;
    font-size: 0.9rem;
}

.filter-btn:hover {
    background: var(--gray-200);
}

.filter-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary-dark);
}

.filter-current {
    color: var(--gray-600);
    font-size: 0.9rem;
}

.custom-filter-form {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--gray-50);
    border-radius: 6px;
}

.form-row {
    display: flex;
    gap: 1rem;
    align-items: end;
}

.form-group label {
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
    color: var(--gray-700);
}

.form-group input[type="date"] {
    padding: 0.5rem;
    border: 1px solid var(--gray-300);
    border-radius: 4px;
    font-size: 0.9rem;
}

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

.kpi-card {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    border-left: 4px solid var(--gray-300);
    transition: transform 0.2s, box-shadow 0.2s;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.kpi-created {
    border-left-color: var(--success);
}

.kpi-modified {
    border-left-color: var(--warning);
}

.kpi-confirmed {
    border-left-color: #3b82f6;
}

.kpi-cancelled {
    border-left-color: var(--error);
}

.kpi-noshow {
    border-left-color: #8b5cf6;
}

.kpi-deleted {
    border-left-color: var(--gray-600);
}

.kpi-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--gray-200);
}

.kpi-icon {
    font-size: 1.5rem;
}

.kpi-header h3 {
    font-size: 1rem;
    color: var(--gray-700);
    margin: 0;
}

.kpi-metrics {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.kpi-metric-primary,
.kpi-metric-secondary {
    text-align: center;
}

.kpi-metric-primary .kpi-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
}

.kpi-metric-secondary .kpi-value {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--gray-700);
}

.kpi-label {
    font-size: 0.75rem;
    color: var(--gray-600);
    margin-top: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-box {
    background: #eff6ff;
    border-left: 4px solid #3b82f6;
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 2rem;
}

.info-box ul {
    padding-left: 1.5rem;
}

.info-box li {
    color: var(--gray-700);
    font-size: 0.9rem;
}

.quick-actions {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.quick-actions h3 {
    margin-top: 0;
    margin-bottom: 1rem;
    color: var(--gray-900);
}

.actions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.action-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--gray-50);
    border-radius: 6px;
    text-decoration: none;
    color: var(--gray-900);
    transition: background 0.2s, transform 0.2s;
}

.action-card:hover {
    background: var(--gray-100);
    transform: translateX(4px);
}

.action-icon {
    font-size: 1.5rem;
}

.action-label {
    font-weight: 500;
}

.header-status {
    display: flex;
    align-items: center;
}

.status-badge {
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.status-online {
    background: #d1fae5;
    color: #065f46;
}

.status-offline {
    background: #fee2e2;
    color: #991b1b;
}

/* === Responsive === */
@media (max-width: 768px) {
    .nav-container {
        flex-direction: column;
        gap: 1rem;
    }
    
    .nav-menu {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .detail-list {
        grid-template-columns: 1fr;
    }
    
    .table-container {
        font-size: 0.85rem;
    }
    
    .data-table th,
    .data-table td {
        padding: 0.5rem;
    }
    
    .kpis-grid {
        grid-template-columns: 1fr;
    }
    
    .form-row {
        flex-direction: column;
    }
    
    .actions-grid {
        grid-template-columns: 1fr;
    }
}
