/* =============================================
   Paleta de Colores - Casa Médica
   ============================================= */
:root {
    --cm-black: #000000;
    --cm-charcoal: #24292D;
    --cm-primary: #14386F;
    --cm-accent: #55A9DD;
    --cm-gray: #BCBEBF;
    --cm-white: #FFFFFF;

    /* Derivados */
    --cm-primary-hover: #1a4a8a;
    --cm-accent-hover: #3d96cc;
    --cm-bg-light: #f4f6f8;
    --cm-border: #BCBEBF;
    --cm-text: #24292D;
    --cm-text-muted: #6c757d;
}

/* General Styles */
html {
    font-size: 14px;
    position: relative;
    min-height: 100%;
}

body {
    margin-bottom: 60px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: var(--cm-text);
}

main {
    min-height: calc(100vh - 160px);
}

/* Footer */
.footer {
    position: absolute;
    bottom: 0;
    width: 100%;
    white-space: nowrap;
    line-height: 60px;
}

/* Navbar */
.navbar-brand {
    font-weight: 700;
    font-size: 1.5rem;
}

/* Cards */
.card {
    border-radius: 8px;
    transition: all 0.3s ease;
}

.card:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

/* Buttons */
.btn {
    border-radius: 6px;
    font-weight: 500;
    transition: all 0.3s ease;
}

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

/* Responsive */
@media (min-width: 768px) {
    html {
        font-size: 16px;
    }
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: var(--cm-gray);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--cm-primary);
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.5s ease-in;
}

/* =============================================
   Sistema de Notificaciones
   ============================================= */

/* Global Banner - Errores de sistema/API */
.notification-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10000;
    transform: translateY(-100%);
    transition: transform 0.3s ease-in-out;
}

.notification-banner.show {
    transform: translateY(0);
}

.notification-banner-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    min-height: 48px;
}

.notification-banner-error {
    background-color: #dc3545;
    color: white;
}

.notification-banner-warning {
    background-color: #ffc107;
    color: #212529;
}

.notification-banner-icon {
    margin-right: 12px;
    font-size: 1.25rem;
}

.notification-banner-message {
    flex: 1;
    font-weight: 500;
}

.notification-banner-close {
    background: transparent;
    border: none;
    color: inherit;
    font-size: 1.5rem;
    line-height: 1;
    padding: 0 8px;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.notification-banner-close:hover {
    opacity: 1;
}

/* Toast / Snackbar Container */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column-reverse;
    gap: 10px;
    pointer-events: none;
}

/* Toast Individual */
.toast-notification {
    display: flex;
    align-items: center;
    min-width: 280px;
    max-width: 400px;
    padding: 14px 16px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    pointer-events: auto;
    transform: translateX(120%);
    transition: transform 0.3s ease-in-out, opacity 0.3s ease-in-out;
    opacity: 0;
}

.toast-notification.show {
    transform: translateX(0);
    opacity: 1;
}

.toast-notification.hide {
    transform: translateX(120%);
    opacity: 0;
}

.toast-success {
    background-color: #198754;
    color: white;
}

.toast-info {
    background-color: #0d6efd;
    color: white;
}

.toast-warning {
    background-color: #ffc107;
    color: #212529;
}

.toast-error {
    background-color: #dc3545;
    color: white;
}

.toast-icon {
    margin-right: 12px;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    margin-bottom: 2px;
}

.toast-message {
    font-size: 0.9rem;
    opacity: 0.9;
}

.toast-close {
    background: transparent;
    border: none;
    color: inherit;
    font-size: 1.25rem;
    padding: 0 0 0 12px;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
    flex-shrink: 0;
}

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

.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background-color: rgba(255, 255, 255, 0.4);
    border-radius: 0 0 8px 8px;
    animation: toastProgress linear forwards;
}

@keyframes toastProgress {
    from { width: 100%; }
    to { width: 0%; }
}

/* Errores Inline de Formulario */
.form-field-wrapper {
    position: relative;
}

.form-control.is-invalid,
.form-select.is-invalid {
    border-color: #dc3545;
    background-image: none;
}

.form-control.is-invalid:focus,
.form-select.is-invalid:focus {
    border-color: #dc3545;
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);
}

.field-error {
    display: none;
    color: #dc3545;
    font-size: 0.85rem;
    margin-top: 4px;
    padding-left: 2px;
}

.field-error.show {
    display: block;
    animation: fadeInError 0.2s ease-in-out;
}

.field-error-icon {
    margin-right: 4px;
}

@keyframes fadeInError {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive para Toast */
@media (max-width: 480px) {
    .toast-container {
        left: 10px;
        right: 10px;
        bottom: 10px;
    }

    .toast-notification {
        min-width: auto;
        max-width: none;
        width: 100%;
    }

    .notification-banner-content {
        padding: 10px 12px;
    }

    .notification-banner-message {
        font-size: 0.9rem;
    }
}

/* Ajuste para MAUI/Hybrid - Safe Area */
@supports (padding-top: env(safe-area-inset-top)) {
    .notification-banner {
        padding-top: env(safe-area-inset-top);
    }

    .toast-container {
        bottom: calc(20px + env(safe-area-inset-bottom));
    }
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.loading-overlay.show {
    opacity: 1;
    visibility: visible;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--cm-gray);
    border-top-color: var(--cm-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* =============================================
   Navbar Override - Brand Colors
   ============================================= */
.navbar.bg-primary,
.navbar.navbar-cm {
    background-color: var(--cm-primary) !important;
}

.navbar .navbar-brand {
    color: var(--cm-white);
}

.navbar .nav-link {
    color: rgba(255, 255, 255, 0.85);
}

.navbar .nav-link:hover {
    color: var(--cm-white);
}

.navbar .dropdown-item:active {
    background-color: var(--cm-primary);
}

/* =============================================
   Button Overrides - Brand Colors
   ============================================= */
.btn-primary {
    background-color: var(--cm-primary);
    border-color: var(--cm-primary);
}

.btn-primary:hover,
.btn-primary:focus {
    background-color: var(--cm-primary-hover);
    border-color: var(--cm-primary-hover);
}

.btn-primary:active {
    background-color: var(--cm-charcoal);
    border-color: var(--cm-charcoal);
}

.btn-outline-primary {
    color: var(--cm-primary);
    border-color: var(--cm-primary);
}

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

/* Accent button */
.btn-accent {
    background-color: var(--cm-accent);
    border-color: var(--cm-accent);
    color: var(--cm-white);
}

.btn-accent:hover {
    background-color: var(--cm-accent-hover);
    border-color: var(--cm-accent-hover);
    color: var(--cm-white);
}

/* =============================================
   Links - Brand Colors
   ============================================= */
a {
    color: var(--cm-primary);
}

a:hover {
    color: var(--cm-accent);
}

/* =============================================
   Scrollbar - Brand Colors
   ============================================= */

@keyframes spin {
    to { transform: rotate(360deg); }
}
