/* ================================================================
   WispHub CRUD Module — Styles
   Sistema Noor · Dark Glassmorphism Design
   ================================================================ */

/* ===== Layout Container ===== */
.wisphub-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    color: var(--text-main);
    animation: wh-fadeIn 0.4s ease forwards;
}

@keyframes wh-fadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== Back Link ===== */
.wh-back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.88rem;
    margin-bottom: 1.5rem;
    transition: color 0.25s;
}

.wh-back-link:hover {
    color: var(--text-main);
}

/* ===== Page Header ===== */
.wh-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.75rem;
    flex-wrap: wrap;
    gap: 12px;
}

.wh-page-header h1 {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.wh-page-header h1 .wh-header-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: rgba(6, 182, 212, 0.15);
    color: #22d3ee;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wh-role-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.wh-role-badge.superadmin {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
}

.wh-role-badge.cobrador {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
}

/* ===== Tabs ===== */
.wh-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 1.75rem;
    padding: 5px;
    background: rgba(15, 23, 42, 0.5);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    overflow-x: auto;
}

.wh-tabs::-webkit-scrollbar { height: 0; }

.wh-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    border: none;
    background: transparent;
    color: var(--text-dim);
    font-size: 0.85rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.25s;
    white-space: nowrap;
    position: relative;
}

.wh-tab:hover {
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.04);
}

.wh-tab.active {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.wh-tab .tab-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.wh-tab .tab-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.wh-tab[data-tab="clientes"] .tab-dot { background: #22d3ee; }
.wh-tab[data-tab="servicios"] .tab-dot { background: #34d399; }
.wh-tab[data-tab="facturas"] .tab-dot { background: #fbbf24; }
.wh-tab[data-tab="pagos"] .tab-dot { background: #818cf8; }
.wh-tab[data-tab="catalogos"] .tab-dot { background: #f472b6; }

.wh-tab.active[data-tab="clientes"] { border-bottom: 2px solid #22d3ee; }
.wh-tab.active[data-tab="servicios"] { border-bottom: 2px solid #34d399; }
.wh-tab.active[data-tab="facturas"] { border-bottom: 2px solid #fbbf24; }
.wh-tab.active[data-tab="pagos"] { border-bottom: 2px solid #818cf8; }
.wh-tab.active[data-tab="catalogos"] { border-bottom: 2px solid #f472b6; }

/* ===== Tab Content Panel ===== */
.wh-panel {
    display: none;
    animation: wh-fadeIn 0.3s ease forwards;
}

.wh-panel.active {
    display: block;
}

/* ===== Toolbar (Search + Actions) ===== */
.wh-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.wh-search-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    max-width: 480px;
}

.wh-search-input {
    flex: 1;
    padding: 10px 14px 10px 38px;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    font-size: 0.88rem;
    font-family: inherit;
    transition: all 0.25s;
    outline: none;
    position: relative;
}

.wh-search-wrapper {
    position: relative;
    flex: 1;
}

.wh-search-wrapper svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-dim);
    pointer-events: none;
}

.wh-search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.wh-filter-select {
    padding: 10px 14px;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    font-size: 0.85rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.25s;
    cursor: pointer;
    min-width: 140px;
}

.wh-filter-select:focus {
    border-color: var(--primary);
}

.wh-filter-select option {
    background: #1e293b;
    color: #f8fafc;
}

.wh-toolbar-actions {
    display: flex;
    gap: 8px;
}

.wh-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.25s;
    font-family: inherit;
    white-space: nowrap;
}

.wh-btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 3px 12px rgba(99, 102, 241, 0.3);
}

.wh-btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 5px 16px rgba(99, 102, 241, 0.4);
}

.wh-btn-success {
    background: var(--success);
    color: #fff;
    box-shadow: 0 3px 12px rgba(16, 185, 129, 0.25);
}

.wh-btn-success:hover {
    background: #059669;
    transform: translateY(-1px);
}

.wh-btn-danger {
    background: var(--danger);
    color: #fff;
    box-shadow: 0 3px 12px rgba(239, 68, 68, 0.25);
}

.wh-btn-danger:hover {
    background: var(--danger-hover);
    transform: translateY(-1px);
}

.wh-btn-outline {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
}

.wh-btn-outline:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    border-color: var(--border-hover);
}

.wh-btn-sm {
    padding: 6px 12px;
    font-size: 0.78rem;
}

.wh-btn-icon {
    width: 34px;
    height: 34px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
    transition: all 0.25s;
}

.wh-btn-icon:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-main);
}

.wh-btn-icon.danger:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #f87171;
    border-color: rgba(239, 68, 68, 0.3);
}

.wh-btn-icon.success:hover {
    background: rgba(16, 185, 129, 0.1);
    color: #34d399;
    border-color: rgba(16, 185, 129, 0.3);
}

.wh-btn-icon.warning:hover {
    background: rgba(245, 158, 11, 0.1);
    color: #fbbf24;
    border-color: rgba(245, 158, 11, 0.3);
}

/* ===== Data Table ===== */
.wh-table-wrap {
    background: var(--card-bg-solid);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

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

.wh-table thead th {
    padding: 14px 16px;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-dim);
    background: rgba(15, 23, 42, 0.4);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.wh-table tbody tr {
    transition: background 0.2s;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.wh-table tbody tr:last-child {
    border-bottom: none;
}

.wh-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

.wh-table tbody td {
    padding: 13px 16px;
    font-size: 0.88rem;
    color: var(--text-muted);
    vertical-align: middle;
}

.wh-table tbody td:first-child {
    color: var(--text-dim);
    font-weight: 600;
    font-size: 0.82rem;
}

.wh-table .td-name {
    color: var(--text-main);
    font-weight: 600;
}

.wh-table .td-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

/* ===== Status Badges ===== */
.wh-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.3px;
    text-transform: capitalize;
}

/* Servicio states */
.wh-badge-activo {
    background: rgba(16, 185, 129, 0.12);
    color: #34d399;
}

.wh-badge-cortado {
    background: rgba(239, 68, 68, 0.12);
    color: #f87171;
}

.wh-badge-retirado {
    background: rgba(100, 116, 139, 0.15);
    color: #94a3b8;
}

/* Factura states */
.wh-badge-pagada {
    background: rgba(16, 185, 129, 0.12);
    color: #34d399;
}

.wh-badge-no-pagada {
    background: rgba(245, 158, 11, 0.12);
    color: #fbbf24;
}

.wh-badge-anulada {
    background: rgba(239, 68, 68, 0.12);
    color: #f87171;
}

/* Client active/inactive */
.wh-badge-true {
    background: rgba(16, 185, 129, 0.12);
    color: #34d399;
}

.wh-badge-false {
    background: rgba(239, 68, 68, 0.12);
    color: #f87171;
}

/* ===== Pagination ===== */
.wh-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-top: 1px solid var(--border-color);
    background: rgba(15, 23, 42, 0.3);
}

.wh-pagination-info {
    font-size: 0.8rem;
    color: var(--text-dim);
}

.wh-pagination-buttons {
    display: flex;
    gap: 6px;
}

.wh-page-btn {
    padding: 6px 14px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
}

.wh-page-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-main);
}

.wh-page-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

/* ===== Empty State ===== */
.wh-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    color: var(--text-dim);
}

.wh-empty-icon {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    background: rgba(99, 102, 241, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 18px;
}

.wh-empty h3 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.wh-empty p {
    font-size: 0.85rem;
    max-width: 320px;
    line-height: 1.5;
}

/* ===== Skeleton Loader ===== */
.wh-skeleton-row {
    display: flex;
    gap: 16px;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.wh-skeleton {
    height: 14px;
    border-radius: 6px;
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.04) 25%,
        rgba(255, 255, 255, 0.08) 50%,
        rgba(255, 255, 255, 0.04) 75%
    );
    background-size: 200% 100%;
    animation: wh-shimmer 1.5s infinite;
}

@keyframes wh-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ===== Modal ===== */
.wh-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(6px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.wh-modal-overlay.active {
    display: flex;
}

.wh-modal {
    background: #1e293b;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5);
    animation: wh-modalIn 0.3s ease;
}

@keyframes wh-modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.wh-modal::-webkit-scrollbar { width: 5px; }
.wh-modal::-webkit-scrollbar-track { background: transparent; }
.wh-modal::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }

.wh-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 22px 26px 16px;
    border-bottom: 1px solid var(--border-color);
}

.wh-modal-header h3 {
    font-size: 1.15rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.wh-modal-close {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.wh-modal-close:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #f87171;
    border-color: rgba(239, 68, 68, 0.3);
}

.wh-modal-body {
    padding: 22px 26px;
}

.wh-modal-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding: 16px 26px 22px;
    border-top: 1px solid var(--border-color);
}

/* ===== Form Controls (in modal) ===== */
.wh-form-group {
    margin-bottom: 18px;
}

.wh-form-group label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 7px;
}

.wh-form-group input,
.wh-form-group select,
.wh-form-group textarea {
    width: 100%;
    padding: 11px 14px;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    font-size: 0.9rem;
    font-family: inherit;
    transition: all 0.25s;
    outline: none;
}

.wh-form-group input:focus,
.wh-form-group select:focus,
.wh-form-group textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.wh-form-group select option {
    background: #1e293b;
    color: #f8fafc;
}

.wh-form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.wh-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.wh-form-error {
    font-size: 0.8rem;
    color: #fca5a5;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    margin-bottom: 14px;
    display: none;
}

/* ===== Toast Notifications ===== */
.wh-toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.wh-toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    animation: wh-toastIn 0.35s ease, wh-toastOut 0.35s ease 3.65s forwards;
    max-width: 380px;
    backdrop-filter: blur(12px);
}

@keyframes wh-toastIn {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes wh-toastOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(40px); }
}

.wh-toast-success {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #86efac;
}

.wh-toast-error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

.wh-toast-info {
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(99, 102, 241, 0.3);
    color: #c7d2fe;
}

/* ===== Catalog Cards ===== */
.wh-catalog-sections {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.wh-catalog-section h3 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.wh-catalog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
}

.wh-catalog-card {
    background: var(--card-bg-solid);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px 18px;
    transition: all 0.25s;
}

.wh-catalog-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.wh-catalog-card .cc-title {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 8px;
}

.wh-catalog-card .cc-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-muted);
    padding: 3px 0;
}

.wh-catalog-card .cc-row .cc-label {
    color: var(--text-dim);
}

.wh-catalog-card .cc-row .cc-value {
    font-weight: 600;
    color: var(--text-main);
}

/* Money formatting */
.wh-money {
    font-weight: 700;
    color: var(--text-main);
    font-variant-numeric: tabular-nums;
}

.wh-money.positive {
    color: #34d399;
}

.wh-money.negative {
    color: #f87171;
}

/* ===== Cobrador Quick Pay Card ===== */
.wh-quick-pay {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(6, 182, 212, 0.08));
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.wh-quick-pay-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: rgba(99, 102, 241, 0.15);
    color: #818cf8;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.wh-quick-pay-text h3 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 2px;
}

.wh-quick-pay-text p {
    font-size: 0.82rem;
    color: var(--text-muted);
}

/* ===== Detail View (Expand Row) ===== */
.wh-detail-row td {
    padding: 0 !important;
    border-bottom: 1px solid rgba(99, 102, 241, 0.15) !important;
}

.wh-detail-content {
    padding: 16px 20px;
    background: rgba(15, 23, 42, 0.5);
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

.wh-detail-item {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.wh-detail-item .dl {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-dim);
}

.wh-detail-item .dv {
    font-size: 0.88rem;
    color: var(--text-main);
    font-weight: 500;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .wisphub-container {
        padding: 1rem;
    }

    .wh-page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .wh-page-header h1 {
        font-size: 1.35rem;
    }

    .wh-tabs {
        gap: 2px;
        padding: 4px;
    }

    .wh-tab {
        padding: 8px 12px;
        font-size: 0.78rem;
    }

    .wh-tab .tab-icon {
        display: none;
    }

    .wh-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .wh-search-group {
        max-width: none;
    }

    .wh-toolbar-actions {
        justify-content: flex-end;
    }

    .wh-form-row {
        grid-template-columns: 1fr;
    }

    .wh-table thead {
        display: none;
    }

    .wh-table tbody tr {
        display: block;
        padding: 14px 16px;
        border-bottom: 1px solid var(--border-color);
    }

    .wh-table tbody td {
        display: flex;
        justify-content: space-between;
        padding: 5px 0;
        font-size: 0.85rem;
    }

    .wh-table tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-dim);
        font-size: 0.75rem;
        text-transform: uppercase;
        letter-spacing: 0.3px;
    }

    .wh-pagination {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }

    .wh-modal {
        max-width: none;
        margin: 0;
        border-radius: var(--radius-lg);
    }

    .wh-catalog-grid {
        grid-template-columns: 1fr;
    }

    .wh-detail-content {
        grid-template-columns: 1fr;
    }

    .wh-quick-pay {
        flex-direction: column;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .wh-tab {
        padding: 8px 10px;
        font-size: 0.74rem;
        gap: 5px;
    }
}
