/* ═══════════════════════════════════════════════════════════════
   Apple Human Interface Guidelines · Dark Mode Design System
   Tecnocasa · Buscador de Usuarios
   ═══════════════════════════════════════════════════════════════ */

/* ── Design Tokens ─────────────────────────────────────────── */

:root {
    /* Backgrounds */
    --bg-primary: #000000;
    --bg-secondary: #1C1C1E;
    --bg-tertiary: #2C2C2E;
    --bg-hover: #3A3A3C;

    /* Text */
    --text-primary: #F5F5F7;
    --text-secondary: #A1A1A6;
    --text-tertiary: #6E6E73;

    /* Accents */
    --accent: #0A84FF;
    --accent-hover: #409CFF;
    --accent-green: #30D158;
    --accent-red: #FF453A;
    --accent-yellow: #FFD60A;
    --accent-orange: #FF9F0A;

    /* Surfaces & Effects */
    --separator: rgba(84, 84, 88, 0.65);
    --glass-bg: rgba(28, 28, 30, 0.72);
    --shadow-elevated: 0 2px 20px rgba(0, 0, 0, 0.5);

    /* Radii */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    /* Fonts */
    --font-sans: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', sans-serif;
    --font-mono: 'SF Mono', SFMono-Regular, ui-monospace, Menlo, monospace;
}


/* ── Reset & Base ──────────────────────────────────────────── */

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

html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    font-family: var(--font-sans);
    font-size: 17px;
    font-weight: 400;
    line-height: 1.47;
    color: var(--text-primary);
    background: var(--bg-primary);
    min-height: 100vh;
}


/* ── Scrollbar ─────────────────────────────────────────────── */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-hover); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }


/* ── Typography ────────────────────────────────────────────── */

h1 {
    font-size: 34px;
    font-weight: 700;
    letter-spacing: -0.4px;
    color: var(--text-primary);
    line-height: 1.15;
}

h2 {
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.2px;
    color: var(--text-primary);
    line-height: 1.25;
}


/* ── Navbar ─────────────────────────────────────────────────── */

.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    background: var(--glass-bg);
    border-bottom: 1px solid var(--separator);
}

.navbar-inner {
    max-width: 980px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 52px;
    padding: 0 20px;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.navbar-logo {
    width: 32px;
    height: 32px;
    background: var(--accent);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    color: #fff;
    flex-shrink: 0;
}

.navbar-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.2px;
}

.navbar-title span {
    color: var(--text-tertiary);
    font-weight: 400;
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.navbar-stats {
    display: flex;
    gap: 24px;
    font-size: 13px;
    color: var(--text-secondary);
}

.navbar-logout {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
}

.navbar-logout:hover {
    color: var(--accent-red);
    background: rgba(255, 69, 58, 0.12);
}

.stat-value {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: var(--text-primary);
    margin-left: 4px;
}


/* ── Layout ────────────────────────────────────────────────── */

.container {
    max-width: 1320px;
    margin: 0 auto;
    padding: 0 32px;
}

.search-section-inner {
    max-width: 980px;
}


/* ── Search Section ────────────────────────────────────────── */

.search-section {
    padding-top: 32px;
    padding-bottom: 8px;
}

.search-bar {
    position: relative;
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    pointer-events: none;
}

.search-input {
    width: 100%;
    height: 48px;
    padding: 0 16px 0 44px;
    background: var(--bg-tertiary);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 17px;
    font-weight: 400;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.3);
}

.search-input::placeholder {
    color: var(--text-tertiary);
}

.search-clear {
    display: none;
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    background: var(--bg-hover);
    border: none;
    border-radius: 50%;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: background 0.2s ease;
}

.search-clear:hover {
    background: var(--text-tertiary);
    color: var(--text-primary);
}


/* ── Filters ───────────────────────────────────────────────── */

.filters {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.filter-select {
    height: 36px;
    padding: 0 30px 0 12px;
    background: var(--bg-tertiary);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 15px;
    font-weight: 400;
    outline: none;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='none'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%236E6E73' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.filter-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.3);
}

.filter-select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}


/* ── Result Meta ───────────────────────────────────────────── */

.result-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 20px;
    font-size: 13px;
    color: var(--text-secondary);
}

.result-count {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: var(--text-primary);
}


/* ── Table ──────────────────────────────────────────────────── */

.table-section {
    padding-bottom: 48px;
}

.table-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 15px;
    table-layout: fixed;
}

thead th {
    text-align: left;
    padding: 12px 16px;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-tertiary);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--separator);
    white-space: nowrap;
}

tbody tr {
    border-bottom: 1px solid rgba(84, 84, 88, 0.35);
    cursor: pointer;
    transition: background 0.2s ease;
}

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

tbody tr:hover {
    background: var(--bg-hover);
}

/* Column widths (table-layout: fixed) */
.col-id       { width: 60px; }
.col-login    { width: 10%; }
.col-name     { width: 13%; }
.col-apellido { width: 14%; }
.col-email    { width: 18%; }
.col-phone    { width: 11%; }
.col-perfil   { width: 14%; }
.col-estatus  { width: 9%; }

tbody td {
    padding: 14px 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 15px;
}

.col-id {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--text-tertiary);
}

.col-login {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--accent);
}

.col-name {
    font-weight: 500;
    color: var(--text-primary);
}

.col-email {
    color: var(--text-secondary);
    font-size: 14px;
}

.col-phone {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}


/* ── Badges ─────────────────────────────────────────────────── */

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.3px;
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
}

.badge-activo {
    background: rgba(48, 209, 88, 0.15);
    color: var(--accent-green);
}

.badge-inactivo {
    background: rgba(255, 69, 58, 0.15);
    color: var(--accent-red);
}

.badge-perfil {
    background: rgba(10, 132, 255, 0.12);
    color: var(--accent);
}


/* ── Buttons ───────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-sans);
    font-size: 17px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: scale(1.02);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--bg-hover);
}

.btn-destructive {
    background: transparent;
    color: var(--accent-red);
}

.btn-destructive:hover {
    background: rgba(255, 69, 58, 0.12);
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}


/* ── Pagination ────────────────────────────────────────────── */

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    padding: 24px 0 8px;
}

.pagination button {
    min-width: 36px;
    height: 36px;
    padding: 0 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--separator);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.pagination button:hover:not(:disabled) {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.pagination button.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    font-weight: 600;
}

.pagination button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.page-ellipsis {
    font-size: 15px;
    color: var(--text-tertiary);
    padding: 0 6px;
}


/* ── Modal ──────────────────────────────────────────────────── */

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 200;
    align-items: center;
    justify-content: center;
}

.modal-overlay.open {
    display: flex;
    animation: overlayFadeIn 0.2s ease;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--separator);
    border-radius: var(--radius-xl);
    width: 90%;
    max-width: 560px;
    max-height: 80vh;
    overflow-y: auto;
    padding: 28px;
    position: relative;
    box-shadow: var(--shadow-elevated);
}

.modal-overlay.open .modal {
    animation: modalSlideUp 0.3s ease-out;
}

.modal-close {
    position: absolute;
    top: 18px;
    right: 18px;
    width: 28px;
    height: 28px;
    background: var(--bg-tertiary);
    border: none;
    border-radius: 50%;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    line-height: 1;
}

.modal-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.modal h2 {
    margin-bottom: 24px;
    padding-right: 40px;
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.detail-item.full {
    grid-column: 1 / -1;
}

.detail-label {
    font-size: 13px;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-tertiary);
    margin-bottom: 4px;
}

.detail-value {
    font-size: 15px;
    color: var(--text-primary);
    word-break: break-word;
}


/* ── Alerts ─────────────────────────────────────────────────── */

.alert {
    padding: 14px 18px;
    border-radius: var(--radius-md);
    font-size: 15px;
    border-left: 3px solid;
}

.alert-success {
    background: rgba(48, 209, 88, 0.12);
    border-left-color: var(--accent-green);
    color: var(--accent-green);
}

.alert-error {
    background: rgba(255, 69, 58, 0.12);
    border-left-color: var(--accent-red);
    color: var(--accent-red);
}

.alert-warning {
    background: rgba(255, 214, 10, 0.12);
    border-left-color: var(--accent-yellow);
    color: var(--accent-yellow);
}


/* ── Empty State ───────────────────────────────────────────── */

.empty-state {
    text-align: center;
    padding: 64px 20px;
    color: var(--text-tertiary);
}

.empty-state svg {
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-state p {
    font-size: 17px;
    color: var(--text-secondary);
}


/* ── Loading ───────────────────────────────────────────────── */

.loading {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-tertiary);
    font-size: 15px;
}

.spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 2.5px solid rgba(84, 84, 88, 0.35);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 12px;
}


/* ── Animations ────────────────────────────────────────────── */

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

@keyframes overlayFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modalSlideUp {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}


/* ── Reduced Motion ────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}


/* ── Login ─────────────────────────────────────────────────── */

.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    background: var(--bg-secondary);
    border: 1px solid var(--separator);
    border-radius: var(--radius-xl);
    padding: 48px 40px;
    width: 100%;
    max-width: 400px;
    text-align: center;
    box-shadow: var(--shadow-elevated);
    animation: modalSlideUp 0.4s ease-out;
}

.login-logo {
    width: 64px;
    height: 64px;
    background: var(--accent);
    border-radius: var(--radius-lg);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 24px;
    color: #fff;
    margin-bottom: 20px;
}

.login-title {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
}

.login-subtitle {
    font-size: 15px;
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.form-group {
    margin-bottom: 16px;
}

.form-input {
    width: 100%;
    height: 48px;
    padding: 0 16px;
    background: var(--bg-tertiary);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 17px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.3);
}

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

.login-error {
    color: var(--accent-red);
    font-size: 14px;
    min-height: 20px;
    margin-bottom: 8px;
}

.login-btn {
    width: 100%;
    height: 48px;
    margin-top: 8px;
}


/* ── Responsive: Tablet ────────────────────────────────────── */

@media (max-width: 768px) {
    .navbar-inner {
        height: 48px;
    }

    .navbar-stats {
        display: none;
    }

    .search-section {
        padding-top: 20px;
    }

    .search-input {
        font-size: 16px;
    }

    .table-card {
        border-radius: var(--radius-md);
        overflow: auto;
    }

    thead th {
        position: relative;
        top: auto;
    }

    tbody td {
        padding: 12px 14px;
    }

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

    .modal {
        border-radius: var(--radius-lg);
    }
}


/* ── Responsive: Mobile ────────────────────────────────────── */

@media (max-width: 480px) {
    .container {
        padding: 0 12px;
    }

    .filters {
        flex-direction: column;
    }

    .filter-select {
        width: 100%;
        height: 44px;
    }

    .search-input {
        height: 44px;
    }

    thead th {
        padding: 10px 14px;
    }

    tbody td {
        padding: 12px 12px;
        font-size: 14px;
    }

    .modal {
        width: 95%;
        padding: 20px;
    }
}
