/* ═══════════════════════════════════════════════════════════
   AgendaFUCSA — Tema iOS Oscuro
   ═══════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600&display=swap');

:root {
    --bg:        #000000;
    --surface:   #1c1c1e;
    --surface2:  #2c2c2e;
    --surface3:  #3a3a3c;
    --border:    rgba(255,255,255,0.08);
    --text:      #ffffff;
    --text2:     rgba(235,235,245,0.8);
    --text3:     rgba(235,235,245,0.6);
    --accent:    #0a84ff;
    --accent2:   #30d158;
    --danger:    #ff453a;
    --radius:    14px;
    --sidebar-w: 320px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    font-family: 'DM Sans', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, select, textarea { font-family: inherit; }

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface3); border-radius: 2px; }

/* ══ LOGIN ══════════════════════════════════════════════════ */
.login-bg {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    padding: 20px;
}

.login-card {
    width: 100%;
    max-width: 380px;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 40px 32px;
    backdrop-filter: blur(20px);
}

.login-logo { text-align: center; margin-bottom: 36px; }

.login-logo-icon {
    width: 72px; height: 72px;
    background: var(--accent);
    border-radius: 20px;
    display: flex; align-items: center; justify-content: center;
    font-size: 36px; font-weight: 600;
    margin: 0 auto 16px; color: #fff;
}

.login-logo h1 { font-size: 22px; font-weight: 600; margin-bottom: 4px; }
.login-logo p  { font-size: 13px; color: var(--text3); }
.login-form    { display: flex; flex-direction: column; gap: 12px; }

.login-error {
    background: rgba(255,69,58,0.15);
    border: 1px solid rgba(255,69,58,0.3);
    color: var(--danger);
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 14px;
}

/* ── Inputs iOS ───────────────────────────────────────────── */
.input-ios {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    color: var(--text);
    font-size: 16px;
    outline: none;
    transition: border-color 0.2s;
}
.input-ios:focus        { border-color: var(--accent); }
.input-ios::placeholder { color: var(--text3); }
.input-ios.input-error  { border-color: var(--danger); }
.input-ios option       { background: var(--surface2); }
textarea.input-ios      { resize: vertical; }

.input-password-wrap { position: relative; }
.toggle-pass {
    position: absolute; right: 14px; top: 50%;
    transform: translateY(-50%);
    color: var(--accent); font-size: 13px; font-weight: 500;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.slide-down { animation: slideDown 0.25s ease; }

/* ── Botones ─────────────────────────────────────────────── */
.btn-primary {
    background: var(--accent); color: #fff;
    border-radius: var(--radius);
    padding: 14px; font-size: 16px; font-weight: 600;
    width: 100%; transition: opacity 0.2s;
    display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-primary:disabled         { opacity: 0.5; cursor: not-allowed; }
.btn-primary:not(:disabled):hover { opacity: 0.85; }
.btn-primary.btn-sm { width: auto; padding: 10px 20px; font-size: 14px; }

.btn-secondary {
    background: var(--surface3); color: var(--text);
    border-radius: var(--radius); padding: 12px 20px;
    font-size: 14px; font-weight: 500;
}

.btn-icon {
    background: transparent; color: var(--accent);
    font-size: 18px; padding: 6px; border-radius: 8px;
    transition: background 0.15s;
}
.btn-icon:hover { background: var(--surface2); }

.btn-back { color: var(--accent); font-size: 14px; font-weight: 500; display: inline-flex; align-items: center; gap: 4px; }
.btn-volver { display: none; color: var(--accent); font-size: 15px; font-weight: 500; padding: 12px 0; }

.spinner {
    width: 18px; height: 18px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ══ CONTACTOS LAYOUT ════════════════════════════════════════ */
.contactos-layout { display: flex; height: 100vh; overflow: hidden; }

.sidebar-contactos {
    width: var(--sidebar-w); min-width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    overflow: hidden; position: relative;
}

.sidebar-header {
    display: flex; align-items: center; gap: 8px;
    padding: 16px 16px 8px;
    border-bottom: 1px solid var(--border);
}
.sidebar-header h2 { flex: 1; font-size: 20px; font-weight: 600; }

.banner-offline {
    background: rgba(255,159,10,0.15);
    border-bottom: 1px solid rgba(255,159,10,0.3);
    color: #ff9f0a;
    font-size: 12px;
    font-weight: 500;
    text-align: center;
    padding: 6px 12px;
}

.search-box { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.search-box input {
    width: 100%; background: var(--surface2); border: none;
    border-radius: 10px; padding: 8px 12px;
    color: var(--text); font-size: 15px; outline: none;
}
.search-box input::placeholder { color: var(--text3); }

.contactos-lista { flex: 1; overflow-y: auto; padding-right: 24px; }

.letra-header {
    padding: 6px 16px 4px; font-size: 13px; font-weight: 600;
    color: var(--text3); background: var(--surface);
    position: sticky; top: 0;
}

.contacto-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 16px; cursor: pointer;
    transition: background 0.15s;
}
.contacto-item:hover   { background: var(--surface2); }
.contacto-item.selected { background: var(--surface3); }

.contacto-info { display: flex; flex-direction: column; min-width: 0; }
.contacto-nombre {
    font-size: 15px; font-weight: 500;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.contacto-empresa {
    font-size: 13px; color: var(--text3);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.indice-az {
    position: absolute; right: 0; top: 50%; transform: translateY(-50%);
    display: flex; flex-direction: column; align-items: center;
    gap: 1px; padding: 4px 2px;
}
.indice-az span {
    font-size: 11px; font-weight: 600; color: var(--accent);
    cursor: pointer; padding: 1px 4px; border-radius: 4px; line-height: 1.4;
}
.indice-az span:hover { background: var(--surface2); }

.panel-detalle { flex: 1; overflow-y: auto; background: var(--bg); }

.detalle-vacio {
    height: 100%; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    color: var(--text3); gap: 12px;
}
.detalle-vacio-icon { font-size: 64px; opacity: 0.3; }
.detalle-vacio p    { font-size: 15px; }

.detalle-content { padding: 24px 20px; }

.detalle-header {
    display: flex; flex-direction: column;
    align-items: center; text-align: center; margin-bottom: 24px;
}
.detalle-header-text { display: flex; flex-direction: column; align-items: center; }
.detalle-header h2  { font-size: 26px; font-weight: 700; margin: 14px 0 4px; }
.detalle-cargo      { color: var(--text3); font-size: 15px; margin-bottom: 8px; }

.detalle-acciones {
    display: flex; gap: 12px; justify-content: center;
    margin-bottom: 24px; flex-wrap: wrap;
}

.accion-btn {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    padding: 14px 24px; background: var(--surface);
    border-radius: var(--radius); font-size: 13px; font-weight: 500;
    color: var(--accent); transition: background 0.15s; cursor: pointer;
}
.accion-btn span  { font-size: 22px; }
.accion-btn:hover { background: var(--surface2); }

.detalle-campos { background: var(--surface); border-radius: var(--radius); overflow: hidden; }

.campo-row {
    display: flex; padding: 14px 16px;
    border-bottom: 1px solid var(--border); gap: 12px;
}
.campo-row:last-child    { border-bottom: none; }
.campo-row.campo-notas   { flex-direction: column; gap: 6px; }
.campo-label { font-size: 13px; color: var(--text3); min-width: 80px; font-weight: 500; }
.campo-valor { font-size: 15px; color: var(--text); }
.campo-valor.link { color: var(--accent); }

/* ── Avatares ────────────────────────────────────────────── */
.avatar-lg {
    width: 96px; height: 96px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 36px; font-weight: 700;
}
.avatar-sm {
    width: 40px; height: 40px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 15px; font-weight: 600; flex-shrink: 0;
}
.avatar-xs {
    width: 28px; height: 28px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 600; flex-shrink: 0;
}

.color-blue   { background: #1c3a5e; color: #4da3ff; }
.color-green  { background: #0d3320; color: #34c759; }
.color-orange { background: #3d2000; color: #ff9f0a; }
.color-purple { background: #2d1f4a; color: #bf5af2; }
.color-teal   { background: #0a2e2d; color: #5ac8fa; }

.badge-empresa {
    background: var(--surface2); color: var(--text2);
    border-radius: 20px; padding: 4px 12px;
    font-size: 13px; font-weight: 500; margin-top: 4px;
}
.badge { padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge-admin { background: rgba(10,132,255,0.2);  color: var(--accent); }
.badge-user  { background: rgba(48,209,88,0.15);  color: var(--accent2); }

/* ══ ADMIN ═══════════════════════════════════════════════════ */
.admin-layout { min-height: 100vh; background: var(--bg); padding: 24px; }

.admin-header {
    display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px;
}
.admin-header-left { display: flex; align-items: center; gap: 16px; }
.admin-header h1   { font-size: 24px; font-weight: 700; }

.search-admin { margin-bottom: 16px; }
.search-admin .input-ios { max-width: 400px; }

.tabla-container {
    background: var(--surface); border-radius: var(--radius);
    overflow: hidden; overflow-x: auto;
}
.tabla-ios { width: 100%; border-collapse: collapse; font-size: 14px; }
.tabla-ios th {
    padding: 12px 16px; text-align: left;
    font-size: 12px; font-weight: 600; color: var(--text3);
    text-transform: uppercase; letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}
.tabla-ios td { padding: 14px 16px; border-bottom: 1px solid var(--border); color: var(--text); }
.tabla-ios tr:last-child td { border-bottom: none; }
.tabla-ios tr:hover td { background: rgba(255,255,255,0.02); }
.text-dim { color: var(--text3); }

.acciones { display: flex; gap: 8px; }
.btn-accion {
    padding: 6px 14px; border-radius: 8px;
    font-size: 13px; font-weight: 500;
    background: var(--surface2); color: var(--text2);
    transition: background 0.15s;
}
.btn-accion:hover              { background: var(--surface3); }
.btn-accion.btn-danger         { color: var(--danger); }
.btn-accion.btn-danger:hover   { background: rgba(255,69,58,0.15); }

.toggle {
    width: 44px; height: 26px; border-radius: 13px;
    position: relative; cursor: pointer; transition: background 0.2s; flex-shrink: 0;
}
.toggle::after {
    content: ''; position: absolute; top: 3px; left: 3px;
    width: 20px; height: 20px; border-radius: 50%;
    background: #fff; transition: transform 0.2s;
}
.toggle.on  { background: var(--accent2); }
.toggle.off { background: var(--surface3); }
.toggle.on::after { transform: translateX(18px); }

/* ── Modal ───────────────────────────────────────────────── */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.7); backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000; padding: 20px;
}
.modal-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 20px; width: 100%; max-width: 480px;
    max-height: 90vh; display: flex; flex-direction: column; overflow: hidden;
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px 24px 16px; border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 18px; font-weight: 600; }
.btn-cerrar { color: var(--text3); font-size: 18px; padding: 4px; border-radius: 6px; }
.btn-cerrar:hover { background: var(--surface2); color: var(--text); }

.modal-body {
    flex: 1; overflow-y: auto; padding: 20px 24px;
    display: flex; flex-direction: column; gap: 14px;
}
.modal-footer {
    display: flex; gap: 10px; justify-content: flex-end;
    padding: 16px 24px; border-top: 1px solid var(--border);
}

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 13px; font-weight: 500; color: var(--text2); }
.form-check { flex-direction: row; align-items: center; gap: 10px; }
.form-check input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); }

.loading-state, .empty-state {
    padding: 40px; text-align: center; color: var(--text3); font-size: 15px;
}

.toast-error {
    position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
    background: var(--danger); color: #fff;
    padding: 12px 24px; border-radius: 12px;
    font-size: 14px; font-weight: 500; z-index: 2000;
}

.flex-row { display: flex; align-items: center; }
.gap-sm   { gap: 8px; }

/* ══ OTP ═════════════════════════════════════════════════════ */
.otp-hint {
    text-align: center; font-size: 14px; color: var(--text2);
    line-height: 1.5; margin-bottom: 4px;
}
.otp-hint strong { color: var(--text); }

.otp-inputs {
    display: flex; gap: 8px; justify-content: center;
}

.otp-box {
    width: 44px; height: 54px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 12px; text-align: center;
    font-size: 24px; font-weight: 600; color: var(--text);
    outline: none; transition: border-color 0.2s;
    caret-color: transparent;
}
.otp-box:focus { border-color: var(--accent); }

.otp-footer {
    display: flex; justify-content: space-between; align-items: center;
    padding-top: 4px;
}
.otp-timer { font-size: 13px; color: var(--text3); }

.btn-link {
    background: none; border: none; color: var(--accent);
    font-size: 13px; font-weight: 500; cursor: pointer; padding: 0;
}
.btn-link:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-link-gray {
    background: none; border: none; color: var(--text3);
    font-size: 14px; font-weight: 500; cursor: pointer;
    width: 100%; padding: 12px 0; text-align: center;
}
.btn-link-gray:disabled { opacity: 0.4; cursor: not-allowed; }

/* ══ MODAL DISPOSITIVO (Action Sheet) ════════════════════════ */
.device-sheet {
    background: var(--surface);
    border-radius: 24px 24px 0 0;
    padding: 12px 32px 40px;
    width: 100%; max-width: 480px;
    display: flex; flex-direction: column;
    align-items: center; gap: 12px;
    text-align: center;
    animation: slideUp 0.3s ease;
}
.device-sheet-handle {
    width: 40px; height: 4px;
    background: var(--surface3); border-radius: 2px; margin-bottom: 8px;
}
.device-sheet-icon { font-size: 48px; }
.device-sheet h3   { font-size: 18px; font-weight: 600; }
.device-sheet p    { font-size: 14px; color: var(--text3); line-height: 1.5; }
.device-sheet .btn-primary { margin-top: 8px; }

@keyframes slideUp {
    from { transform: translateY(100%); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

/* Overlay centrado en desktop, bottom sheet en mobile */
@media (max-width: 767px) {
    .modal-overlay { align-items: flex-end; padding: 0; }
    .device-sheet  { border-radius: 24px 24px 0 0; }
}
@media (min-width: 768px) {
    .device-sheet {
        border-radius: 24px; padding: 40px 40px 36px;
        max-width: 400px;
    }
}

/* ══ DISPOSITIVOS ════════════════════════════════════════════ */
.dispositivo-row {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 12px; padding: 12px 0;
    border-bottom: 1px solid var(--border);
}
.dispositivo-row:last-child { border-bottom: none; }
.dispositivo-info { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; }
.dispositivo-nombre { font-size: 15px; font-weight: 500; }
.dispositivo-meta   { font-size: 12px; color: var(--text3); }
.dispositivo-ua     { font-size: 11px; color: var(--text3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ══ DESKTOP ═════════════════════════════════════════════════ */
@media (min-width: 768px) {
    .panel-detalle { background: var(--surface2); }

    .btn-volver { display: none; }

    .detalle-content {
        max-width: 700px;
        margin: 32px auto;
        padding: 0;
        background: var(--surface);
        border-radius: 20px;
        overflow: hidden;
        box-shadow: 0 8px 40px rgba(0,0,0,0.5);
    }

    .detalle-header {
        flex-direction: row;
        align-items: center;
        text-align: left;
        gap: 28px;
        padding: 36px 36px 28px;
        border-bottom: 1px solid var(--border);
        margin-bottom: 0;
        background: var(--surface);
    }
    .detalle-header-text { align-items: flex-start; }
    .detalle-header h2   { font-size: 30px; margin: 0 0 4px; }
    .detalle-cargo       { margin-bottom: 10px; }

    .detalle-acciones {
        justify-content: flex-start;
        padding: 20px 36px;
        margin-bottom: 0;
        border-bottom: 1px solid var(--border);
        background: var(--surface);
    }

    .detalle-campos {
        border-radius: 0;
        background: var(--surface);
    }
    .campo-row     { padding: 16px 36px; }
    .campo-label   { min-width: 100px; }

    .detalle-vacio p { font-size: 16px; }
}

/* ══ MOBILE ══════════════════════════════════════════════════ */
@media (max-width: 767px) {
    .contactos-layout { position: relative; }

    .sidebar-contactos {
        width: 100%; min-width: 100%;
        position: absolute; inset: 0;
        transition: transform 0.3s ease; z-index: 1;
    }
    .panel-detalle {
        position: absolute; inset: 0;
        transform: translateX(100%);
        transition: transform 0.3s ease; z-index: 2; background: var(--bg);
    }
    .contactos-layout.mostrar-detalle .sidebar-contactos { transform: translateX(-100%); }
    .contactos-layout.mostrar-detalle .panel-detalle     { transform: translateX(0); }

    .btn-volver   { display: block; }
    .detalle-content { padding: 16px; }
    .admin-layout { padding: 16px; }
    .tabla-ios td, .tabla-ios th { padding: 10px 12px; }
}
