/**
 * Estilos adicionales para el SaaS
 */

/* ========================================
   LOGIN / REGISTER
   ======================================== */

/* Mobile-first: sin overflow hidden, permite scroll natural */
html:has(.auth-container),
html:has(.auth-container) body {
    margin: 0;
    padding: 0;
}

.auth-container {
    min-height: 100vh;
    display: flex;
}

/* Desktop: layout fijo de dos columnas sin scroll de página */
@media (min-width: 993px) {
    html:has(.auth-container),
    html:has(.auth-container) body {
        height: 100%;
        overflow: hidden;
    }
    .auth-container {
        height: 100%;
    }
}

.auth-branding {
    flex: 1;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 60px;
    color: white;
    position: relative;
    overflow: hidden;
}

.auth-branding::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
}

.auth-branding h1 {
    font-size: 42px;
    font-weight: 800;
    margin-bottom: 16px;
    position: relative;
    z-index: 1;
}

.auth-branding p {
    font-size: 18px;
    opacity: 0.9;
    max-width: 400px;
    text-align: center;
    line-height: 1.7;
    position: relative;
    z-index: 1;
}

.auth-branding .features-list {
    list-style: none;
    margin-top: 40px;
    position: relative;
    z-index: 1;
}

.auth-branding .features-list li {
    padding: 8px 0;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.auth-branding .features-list li i {
    color: #4ade80;
    font-size: 18px;
}

.auth-form-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    background: var(--gray-50);
}

.auth-form-wrapper {
    width: 100%;
    max-width: 440px;
}

.auth-form-wrapper .logo-text {
    font-size: 28px;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 8px;
}

.auth-form-wrapper h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-800);
    margin-bottom: 8px;
}

.auth-form-wrapper .subtitle {
    color: var(--gray-500);
    margin-bottom: 32px;
    font-size: 15px;
}

.password-toggle {
    position: relative;
}

.password-toggle .toggle-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--gray-400);
    cursor: pointer;
    padding: 4px;
}

.password-toggle .toggle-btn:hover {
    color: var(--gray-600);
}

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: var(--spacing-md);
}

.form-check input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

.auth-footer {
    text-align: center;
    margin-top: 24px;
    color: var(--gray-500);
    font-size: 14px;
}

.auth-footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.auth-footer a:hover {
    text-decoration: underline;
}

@media (max-width: 992px) {
    .auth-branding {
        display: none;
    }

    .auth-form-container {
        align-items: flex-start;
        padding: 20px 20px 40px; /* menos padding top para que logo sea lo primero */
        min-height: 100vh;
        overflow-y: auto;
    }
}

/* ========================================
   HEADER
   ======================================== */

.main-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: white;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 1000;
    box-shadow: var(--shadow-sm);
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 20px;
    font-weight: 800;
    color: var(--primary);
    text-decoration: none;
    flex-shrink: 0;
}

.header-brand i {
    font-size: 24px;
}

.header-search-wrapper {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 400px;
    max-width: calc(100vw - 480px);
    pointer-events: none;
}

.header-search-wrapper > div {
    pointer-events: auto;
}

.header-search {
    width: 100%;
    max-width: 400px;
    position: relative;
}

.header-search input {
    width: 100%;
    padding: 10px 16px 10px 40px;
    border: 2px solid var(--gray-200);
    border-radius: 25px;
    font-size: 14px;
    background: var(--gray-50);
    transition: all 0.3s;
}

.header-search input:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 4px rgba(43, 92, 138, 0.1);
}

.header-search i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-action-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gray-100);
    border: none;
    color: var(--gray-600);
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
}

.header-action-btn:hover {
    background: var(--gray-200);
    color: var(--primary);
}

.header-action-btn .badge-dot {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    background: var(--danger);
    border-radius: 50%;
    border: 2px solid white;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: var(--border-radius-md);
    transition: background 0.2s;
}

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

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 14px;
}

.user-info {
    line-height: 1.3;
}

.user-info .name {
    font-weight: 600;
    font-size: 14px;
    color: var(--gray-800);
}

.user-info .role {
    font-size: 12px;
    color: var(--gray-500);
}

/* ========================================
   SIDEBAR
   ======================================== */

.main-sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: white;
    border-right: 1px solid var(--gray-200);
    overflow-y: auto;
    z-index: 999;
    padding: 20px 0;
    transition: width 0.3s ease;
}

.sidebar-section {
    margin-bottom: 8px;
}

.sidebar-section-title {
    padding: 8px 24px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--gray-400);
}

.sidebar-nav {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 24px;
    color: var(--gray-600);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.sidebar-nav li a:hover {
    background: var(--gray-50);
    color: var(--primary);
}

.sidebar-nav li a.active {
    background: rgba(43, 92, 138, 0.08);
    color: var(--primary);
    border-left-color: var(--primary);
    font-weight: 600;
}

.sidebar-nav li a i {
    width: 20px;
    text-align: center;
    font-size: 16px;
}

/* ========================================
   WELCOME CARD (DASHBOARD)
   ======================================== */

.welcome-card {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
    border-radius: var(--border-radius-xl);
    padding: 30px;
    color: white;
    margin-bottom: var(--spacing-lg);
    position: relative;
    overflow: hidden;
}

.welcome-card::before {
    content: '';
    position: absolute;
    top: -30%;
    right: -10%;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(255,255,255,0.15) 0%, transparent 70%);
    border-radius: 50%;
}

.welcome-card h2 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
}

.welcome-card p {
    opacity: 0.9;
    font-size: 15px;
}

/* ========================================
   QUICK ACTIONS
   ======================================== */

.quick-actions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.quick-action-card {
    background: white;
    border-radius: var(--border-radius-lg);
    padding: 24px;
    border: 1px solid var(--gray-200);
    text-decoration: none;
    color: var(--gray-700);
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 12px;
}

.quick-action-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    color: var(--primary);
}

.quick-action-card i {
    font-size: 32px;
    color: var(--primary);
}

.quick-action-card span {
    font-weight: 600;
    font-size: 14px;
}

/* ========================================
   WIZARD STEPS
   ======================================== */

.wizard-steps {
    display: flex;
    justify-content: center;
    gap: 0;
    margin-bottom: var(--spacing-lg);
}

.wizard-step {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    color: var(--gray-400);
    font-weight: 600;
    font-size: 14px;
    position: relative;
}

.wizard-step .step-number {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
}

.wizard-step.active {
    color: var(--primary);
}

.wizard-step.active .step-number {
    background: var(--primary);
    color: white;
}

.wizard-step.completed {
    color: var(--success);
}

.wizard-step.completed .step-number {
    background: var(--success);
    color: white;
}

.wizard-connector {
    width: 60px;
    height: 2px;
    background: var(--gray-200);
    align-self: center;
}

.wizard-connector.active {
    background: var(--primary);
}

/* ========================================
   MODAL OVERRIDES
   ======================================== */

.modal-content {
    border-radius: var(--border-radius-lg);
    border: none;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    border-bottom: 1px solid var(--gray-200);
    padding: 20px 24px;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    border-top: 1px solid var(--gray-200);
    padding: 16px 24px;
}

/* ========================================
   EMPTY STATE
   ======================================== */

.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-state i {
    font-size: 64px;
    color: var(--gray-300);
    margin-bottom: 16px;
}

.empty-state h3 {
    font-size: 20px;
    font-weight: 600;
    color: var(--gray-600);
    margin-bottom: 8px;
}

.empty-state p {
    color: var(--gray-500);
    margin-bottom: 24px;
}

/* ========================================
   TAB STYLES
   ======================================== */

.nav-tabs-custom {
    border-bottom: 2px solid var(--gray-200);
    gap: 0;
}

.nav-tabs-custom .nav-link {
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--gray-500);
    font-weight: 600;
    padding: 12px 20px;
    margin-bottom: -2px;
    transition: all 0.2s;
}

.nav-tabs-custom .nav-link:hover {
    color: var(--primary);
    border-bottom-color: var(--gray-300);
}

.nav-tabs-custom .nav-link.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: transparent;
}

/* ========================================
   SYSTEM STATUS
   ======================================== */

.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
}

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

.status-dot.online { background: var(--success); }
.status-dot.warning { background: var(--warning); }
.status-dot.offline { background: var(--danger); }

/* ========================================
   LOADING / WIRE TRANSITIONS
   ======================================== */

[wire\:loading] {
    display: inline-block;
}

.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: inherit;
}

.spinner-border-sm {
    width: 1rem;
    height: 1rem;
}

/* ========================================
   TOAST CONTAINER
   ======================================== */

.toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast-item {
    padding: 14px 20px;
    border-radius: var(--border-radius-md);
    color: white;
    font-weight: 500;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: var(--shadow-md);
    animation: slideInRight 0.3s ease;
    min-width: 300px;
}

.toast-item.success { background: var(--success); }
.toast-item.error { background: var(--danger); }
.toast-item.warning { background: var(--warning); }
.toast-item.info { background: var(--info); }

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Items table for comprobantes */
.items-table .remove-item {
    color: var(--danger);
    cursor: pointer;
    border: none;
    background: none;
    font-size: 18px;
    padding: 4px 8px;
}

.items-table .remove-item:hover {
    background: #fee;
    border-radius: var(--border-radius-sm);
}

/* ========================================
   SIDEBAR TOGGLE BUTTON (hamburguesa)
   ======================================== */

.btn-sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    border: none;
    background: none;
    color: var(--gray-600);
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    flex-shrink: 0;
}

.btn-sidebar-toggle:hover {
    background: var(--gray-100);
    color: var(--primary);
}

.btn-sidebar-toggle i {
    font-size: 17px;
    pointer-events: none;
}

/* ========================================
   SIDEBAR COLAPSADO (desktop)
   ======================================== */

body.sidebar-collapsed .main-sidebar {
    width: var(--sidebar-collapsed-width) !important;
}

body.sidebar-collapsed .main-content {
    margin-left: var(--sidebar-collapsed-width) !important;
}


body.sidebar-collapsed .sidebar-section-title {
    display: none !important;
}

body.sidebar-collapsed .sidebar-tenant-info {
    display: none !important;
}

/* Ocultar texto de los links: font-size:0 oculta texto, <i> restaura su tamaño */
body.sidebar-collapsed .sidebar-nav li a {
    font-size: 0 !important;
    justify-content: center !important;
    padding: 11px 0 !important;
    border-left: 3px solid transparent !important;
}

body.sidebar-collapsed .sidebar-nav li a.active {
    background: rgba(43, 92, 138, 0.08);
    border-left-color: var(--primary) !important;
}

body.sidebar-collapsed .sidebar-nav li a i {
    font-size: 18px !important;
    width: auto !important;
    margin: 0 !important;
}

/* Tooltip flotante via JS (ver app.blade.php) */
#sidebar-tooltip {
    position: fixed;
    background: #1e293b;
    color: #fff;
    padding: 5px 11px;
    border-radius: 7px;
    font-size: 12px;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    white-space: nowrap;
    z-index: 9999;
    pointer-events: none;
    display: none;
    transform: translateY(-50%);
    box-shadow: 0 2px 8px rgba(0,0,0,.25);
}

#sidebar-tooltip::before {
    content: '';
    position: absolute;
    right: 100%;
    top: 50%;
    transform: translateY(-50%);
    border: 5px solid transparent;
    border-right-color: #1e293b;
}

/* Backdrop: oculto por defecto en todos los tamaños */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1049;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.sidebar-backdrop.show {
    display: block;
}

/* Responsive sidebar */
@media (max-width: 991.98px) {
    .main-sidebar {
        transform: translateX(-100%);
        z-index: 1050;
        width: var(--sidebar-width) !important;
        transition: transform 0.28s ease;
        box-shadow: none;
    }
    .main-sidebar.show {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0,0,0,0.18);
    }
    .main-content {
        margin-left: 0 !important;
    }
    body.sidebar-collapsed .main-content {
        margin-left: 0 !important;
    }
}

/* Responsive header */
@media (max-width: 576px) {
    .main-header {
        padding: 0 6px;
        height: 56px;
    }

    .header-brand {
        width: auto;
    }

    .header-brand img {
        height: 36px !important;
    }

    .main-header {
        justify-content: flex-start;
        gap: 8px;
    }

    .header-actions {
        margin-left: auto;
    }

    :root {
        --header-height: 56px;
    }

    .header-actions {
        gap: 4px;
    }

    .header-action-btn {
        width: 32px;
        height: 32px;
    }

    .user-avatar {
        width: 30px;
        height: 30px;
        font-size: 12px;
    }

    .user-menu {
        padding: 4px 6px;
        gap: 6px;
    }
}

/* Dropdown responsive */
@media (max-width: 576px) {
    .dropdown-menu {
        position: fixed !important;
        bottom: 0;
        left: 0 !important;
        right: 0 !important;
        top: auto !important;
        transform: none !important;
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
        padding: 8px 0;
        width: 100% !important;
    }

    .dropdown-item {
        padding: 12px 20px;
        font-size: 15px;
    }
}

/* ========================================
   NOTIFICACIONES DROPDOWN
   ======================================== */

.notif-wrapper {
    position: relative;
    display: inline-block;
}

/* Badge número sobre la campana */
.notif-badge {
    position: absolute;
    top: -3px;
    right: -5px;
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    border-radius: 10px;
    min-width: 17px;
    height: 17px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid #fff;
    line-height: 1;
}

/* Panel principal */
.notif-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 10px);
    width: 380px;
    max-height: 480px;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.14);
    border: 1px solid var(--gray-200);
    z-index: 1050;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Cabecera del panel */
.notif-panel-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--gray-100);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.notif-panel-title {
    font-weight: 700;
    font-size: 14px;
    color: var(--gray-800);
    display: flex;
    align-items: center;
}

.notif-count-badge {
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    border-radius: 10px;
    padding: 1px 7px;
    margin-left: 6px;
}

.notif-mark-all {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background 0.15s;
    white-space: nowrap;
}
.notif-mark-all:hover { background: var(--gray-100); }

/* Lista scrollable */
.notif-list {
    overflow-y: auto;
    flex: 1;
}

/* Item individual */
.notif-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 13px 18px;
    border-bottom: 1px solid var(--gray-50);
    cursor: pointer;
    transition: background 0.15s;
}
.notif-item:hover          { background: var(--gray-50); }
.notif-item--unread        { background: rgba(79,70,229,0.04); }
.notif-item--unread:hover  { background: rgba(79,70,229,0.08); }

.notif-icon {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: center;
}

.notif-content  { flex: 1; min-width: 0; }

.notif-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 2px;
    line-height: 1.3;
}

.notif-msg {
    font-size: 12px;
    color: var(--gray-500);
    line-height: 1.4;
}

.notif-time {
    font-size: 11px;
    color: var(--gray-400);
    margin-top: 4px;
}

.notif-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary);
    flex-shrink: 0;
    margin-top: 5px;
}

/* Estado vacío */
.notif-empty {
    padding: 44px 20px;
    text-align: center;
}
.notif-empty i {
    font-size: 34px;
    color: var(--gray-300);
    display: block;
    margin-bottom: 10px;
}
.notif-empty p {
    color: var(--gray-500);
    font-size: 14px;
    margin: 0;
}

/* Responsive: móvil — panel ocupa casi toda la pantalla */
@media (max-width: 576px) {
    .notif-panel {
        position: fixed;
        top: 62px;
        left: 8px;
        right: 8px;
        width: auto;
        max-height: calc(100dvh - 80px);
        border-radius: 14px;
    }
}
