/* ==============================================
   Estilos globales - xpagos-multi
   Design System: XPYME v1.2.0
   ============================================== */

/* Reset y fuentes — Inter obligatoria (Design System §8.3) */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

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

:root {
    /* Paleta XPYME — Tokens Nivel 2 (Semánticos) */
    --color-primary-base: #0097A7;
    --color-primary-hover: #00838F;
    --color-primary-light: #B2EBF2;
    --color-secondary-base: #37474F;
    --color-secondary-light: #546E7A;

    --color-success: #28A745;
    --color-error: #DC3545;
    --color-warning: #FFC107;
    --color-info: #17A2B8;

    /* Superficies — Fondo claro XPYME */
    --surface-app: #F8F9FA;
    --surface-main: #FFFFFF;
    --surface-card: #FFFFFF;
    --surface-sidebar: #37474F;

    /* Textos */
    --text-main: #212529;
    --text-secondary: #495057;
    --text-muted: #868E96;
    --text-on-dark: #FFFFFF;
    --text-on-primary: #FFFFFF;

    /* Bordes */
    --border-subtle: #DEE2E6;
    --border-focus: var(--color-primary-base);

    /* Sombras */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);

    /* Radios — Sistema 8pt XPYME */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 16px;
    --radius-full: 9999px;

    /* Transiciones */
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);

    /* Focus visible — Accesibilidad WCAG AA */
    --state-focus-ring: 0 0 0 3px rgba(0, 151, 167, 0.3);
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--surface-app);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ==============================================
   Layout principal
   ============================================== */
.page-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
}

/* ==============================================
   Hero / Branding — Logo de imagen
   ============================================== */
.hero-brand {
    text-align: center;
    margin-bottom: 2.5rem;
}

.hero-brand .logo-img {
    max-width: 200px;
    height: auto;
    margin-bottom: 0.5rem;
}

.hero-brand h1 {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -1px;
    color: var(--color-primary-base);
}

.hero-brand .subtitle {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 0.3rem;
    font-weight: 400;
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* ==============================================
   Card / Panel — Estilo limpio XPYME
   ============================================== */
.glass-card {
    background: var(--surface-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
    transition: var(--transition-smooth);
}

.glass-card:hover {
    border-color: rgba(0, 151, 167, 0.25);
    box-shadow: var(--shadow-lg), 0 0 0 1px rgba(0, 151, 167, 0.1);
}

/* ==============================================
   Formulario — Inputs y Labels
   ============================================== */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.6rem;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="email"] {
    width: 100%;
    padding: 0.9rem 1.2rem;
    font-size: 1rem;
    font-family: 'Inter', sans-serif;
    color: var(--text-main);
    background: var(--surface-main);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    outline: none;
    transition: var(--transition-fast);
}

.form-group input:focus {
    border-color: var(--color-primary-base);
    box-shadow: var(--state-focus-ring);
}

.form-group input::placeholder {
    color: var(--text-muted);
}

/* ==============================================
   Botón principal — Teal XPYME
   ============================================== */
.btn-primary {
    width: 100%;
    padding: 0.9rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    color: var(--text-on-primary);
    background: var(--color-primary-base);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-smooth);
    position: relative;
    overflow: hidden;
}

.btn-primary:hover {
    background: var(--color-primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 151, 167, 0.3);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:focus-visible {
    box-shadow: var(--state-focus-ring);
}

/* ==============================================
   Mensajes de error y éxito
   ============================================== */
.alert-error {
    background: rgba(220, 53, 69, 0.08);
    border: 1px solid rgba(220, 53, 69, 0.2);
    color: var(--color-error);
    padding: 0.8rem 1.2rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin-bottom: 1.5rem;
    animation: shake 0.4s ease-in-out;
}

.alert-success {
    background: rgba(40, 167, 69, 0.08);
    border: 1px solid rgba(40, 167, 69, 0.2);
    color: var(--color-success);
    padding: 0.8rem 1.2rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin-bottom: 1.5rem;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* ==============================================
   Footer
   ============================================== */
.page-footer {
    margin-top: 2rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* ==============================================
   Layout con Sidebar — Estilo XPYME Corporativo
   ============================================== */
.app-layout {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

.app-layout.has-sidebar .main-content {
    flex: 1;
    margin-left: 280px;
    width: calc(100% - 280px);
    transition: var(--transition-smooth);
}

.main-content {
    width: 100%;
}

/* Sidebar — Fondo Slate XPYME (claro/corporativo) */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    background: var(--surface-sidebar);
    border-right: 1px solid rgba(0, 0, 0, 0.1);
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: var(--transition-smooth);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar-brand .brand-icon {
    width: 26px;
    height: 26px;
    color: var(--color-primary-light);
}

.sidebar-brand h2 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-on-dark);
}

/* Información del cliente en la sidebar (nombre + rut) */
.sidebar-client-info {
    padding: 1rem;
    margin-bottom: 1.5rem;
    background: rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-md);
}

.sidebar-client-info .client-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-on-dark);
    line-height: 1.3;
}

.sidebar-client-info .client-rut {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 2px;
}

.sidebar-section {
    margin-bottom: 1.5rem;
}

.sidebar-section h3 {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: rgba(255, 255, 255, 0.45);
    margin-bottom: 0.8rem;
    font-weight: 700;
}

.sidebar-info-item {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 0.6rem;
}

.sidebar-info-item i {
    width: 16px;
    height: 16px;
    color: var(--color-primary-light);
    flex-shrink: 0;
}

.sidebar-info-item a {
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    transition: var(--transition-fast);
}

.sidebar-info-item a:hover {
    color: var(--text-on-dark);
}

.sidebar-menu {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.7rem 1rem;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition-fast);
    background: transparent;
    border: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
}

.menu-item i {
    width: 18px;
    height: 18px;
    transition: var(--transition-fast);
}

.menu-item:hover {
    color: var(--text-on-dark);
    background: rgba(255, 255, 255, 0.08);
}

.menu-item.active {
    color: var(--text-on-dark);
    background: rgba(0, 151, 167, 0.25);
    border-left: 3px solid var(--color-primary-light);
}

.menu-item.active i {
    color: var(--color-primary-light);
}

.menu-item.logout {
    color: rgba(255, 255, 255, 0.5);
    margin-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0;
    padding-top: 1rem;
}

.menu-item.logout:hover {
    background: rgba(220, 53, 69, 0.15);
    color: #FF6B7A;
}

/* Sidebar footer/branding */
.sidebar-footer {
    margin-top: auto;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
}

.sidebar-footer span {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.35);
    font-weight: 500;
}

/* Botón flotante del menú en móviles */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 1.2rem;
    left: 1.2rem;
    z-index: 110;
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background: var(--surface-sidebar);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-on-dark);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    transition: var(--transition-fast);
}

.sidebar-toggle:hover {
    background: var(--color-secondary-light);
    transform: scale(1.05);
}

/* ==============================================
   Tablas de documentos y transacciones
   ============================================== */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-md);
}

.documents-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.documents-table thead th {
    background: var(--surface-app);
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    padding: 0.8rem 0.6rem;
    text-align: left;
    border-bottom: 2px solid var(--border-subtle);
    white-space: nowrap;
}

.documents-table tbody td {
    padding: 0.7rem 0.6rem;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-main);
    vertical-align: middle;
}

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

.documents-table tbody tr:hover {
    background: rgba(0, 151, 167, 0.04);
}

/* Badges de estado */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-pagado {
    background: rgba(40, 167, 69, 0.1);
    color: var(--color-success);
}

.badge-vencido {
    background: rgba(220, 53, 69, 0.1);
    color: var(--color-error);
}

.badge-pendiente {
    background: rgba(255, 193, 7, 0.15);
    color: #D39E00;
}

/* ==============================================
   Responsive
   ============================================== */
@media (max-width: 992px) {
    .app-layout.has-sidebar .main-content {
        margin-left: 0;
        width: 100%;
    }

    .sidebar {
        left: -280px;
    }

    .sidebar.open {
        left: 0;
        box-shadow: 5px 0 30px rgba(0, 0, 0, 0.3);
    }

    .sidebar-toggle {
        display: flex;
    }

    .hero-brand {
        margin-top: 2rem;
    }
}

@media (max-width: 480px) {
    .hero-brand h1 {
        font-size: 2rem;
    }

    .glass-card {
        padding: 2rem 1.5rem;
        border-radius: var(--radius-md);
    }

    .page-container {
        padding: 1.5rem;
    }
}
