:root {
    --primary: #1b4332;
    --primary-light: #2d6a4f;
    --primary-gradient: linear-gradient(135deg, #1b4332 0%, #081c15 100%);
    --bg-color: #f1f5f9;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --card-bg: #ffffff;
    --border-color: #e2e8f0;
    --error: #ef4444;
    --warning: #f59e0b;
    --success: #10b981;
    --whatsapp: #25D366;
    --info: #0284c7;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    padding-bottom: 80px; /* Espacio para barra inferior */
    min-height: 100vh;
}

/* Header */
.app-header {
    background: var(--primary-gradient);
    color: white;
    position: relative;
    padding-bottom: 28px; 
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px 6px;
    position: relative;
    z-index: 2;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo i {
    font-size: 1.4rem;
    background: rgba(255,255,255,0.15);
    padding: 7px;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.logo-text h1 {
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.1;
}

.logo-text span {
    font-size: 0.65rem;
    color: rgba(255,255,255,0.75);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    display: block;
}

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

.status-indicator {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 5px 9px;
    border-radius: 20px;
    background: rgba(255,255,255,0.18);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    gap: 4px;
    border: 1px solid rgba(255,255,255,0.12);
}

.status-indicator.offline {
    background: var(--error);
    border-color: transparent;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #4ade80;
    display: inline-block;
}

.status-indicator.offline .status-dot {
    background: #ffffff;
}

/* Botón Sincronizar */
.btn-header-action {
    position: relative;
    background: rgba(255,255,255,0.18);
    border: 1px solid rgba(255,255,255,0.12);
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    backdrop-filter: blur(5px);
}

.btn-header-action:active {
    transform: scale(0.92);
    background: rgba(255,255,255,0.3);
}

.badge-count {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--error);
    color: white;
    font-size: 0.6rem;
    font-weight: 800;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0 3px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

.header-curve {
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 25px;
    background: var(--bg-color);
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    z-index: 1;
}

/* Main Area */
.app-main {
    padding: 0 14px;
    max-width: 580px;
    margin: -12px auto 0;
    position: relative;
    z-index: 3;
}

/* View Section Control */
.view-section {
    display: none;
    animation: fadeIn 0.25s ease-in-out;
}
.view-section.active {
    display: block;
}

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

/* Formulario Card */
.registro-form {
    background: var(--card-bg);
    padding: 20px 16px;
    border-radius: 16px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.04);
    border: 1px solid rgba(226, 232, 240, 0.8);
    margin-bottom: 20px;
}

.form-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 3px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 18px;
}

/* Banner de Modo Edición */
.edit-mode-banner {
    background: #eff6ff;
    border: 1.5px solid #bfdbfe;
    color: #1d4ed8;
    padding: 10px 12px;
    border-radius: 10px;
    margin-bottom: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.82rem;
    font-weight: 600;
}

.btn-cancel-edit {
    background: #e2e8f0;
    border: none;
    color: #334155;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
}

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

.form-row {
    display: flex;
    gap: 10px;
}

.half {
    flex: 1;
}

label {
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    margin-bottom: 5px;
    color: var(--text-main);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Input con Iconos */
.input-with-icon {
    position: relative;
    display: flex;
    align-items: center;
}

.input-with-icon i {
    position: absolute;
    left: 13px;
    color: #94a3b8;
    font-size: 0.9rem;
    pointer-events: none;
}

input, select {
    width: 100%;
    padding: 12px 12px 12px 38px;
    border: 1.5px solid var(--border-color);
    border-radius: 10px;
    font-size: 0.9rem;
    background: #f8fafc;
    color: var(--text-main);
    transition: all 0.2s ease;
}

.select-wrapper::after {
    content: '\f107';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    right: 13px;
    color: #94a3b8;
    pointer-events: none;
}

select {
    appearance: none;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(27, 67, 50, 0.1);
}

/* Botón Guardar */
.btn-submit {
    width: 100%;
    background: var(--primary-gradient);
    color: white;
    border: none;
    padding: 14px;
    border-radius: 10px;
    font-size: 0.98rem;
    font-weight: 700;
    cursor: pointer;
    margin-top: 14px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    box-shadow: 0 6px 16px rgba(27, 67, 50, 0.25);
    transition: all 0.2s ease;
}

.btn-submit:active {
    transform: translateY(1px);
    box-shadow: 0 3px 8px rgba(27, 67, 50, 0.2);
}

.btn-submit.btn-warning-action {
    background: linear-gradient(135deg, #ea580c 0%, #c2410c 100%);
    box-shadow: 0 6px 16px rgba(234, 88, 12, 0.3);
}

/* =========================================
   BUSCADOR Y DIRECTORIO DE PERSONAS
   ========================================= */
.search-box-container {
    margin-bottom: 12px;
}

.search-bar {
    position: relative;
    display: flex;
    align-items: center;
}

.search-bar input {
    padding-left: 38px;
    padding-right: 32px;
    background: #ffffff;
    border: 1.5px solid var(--border-color);
}

.search-bar i.search-icon {
    position: absolute;
    left: 13px;
    color: var(--text-muted);
}

.search-bar button.btn-clear-search {
    position: absolute;
    right: 10px;
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 1rem;
    cursor: pointer;
    display: none;
}

.persona-stats-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 2px;
    margin-bottom: 10px;
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 600;
}

.persona-card {
    background: white;
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 10px;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 8px rgba(0,0,0,0.02);
}

.persona-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 6px;
}

.persona-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.2;
}

.persona-cc-badge {
    background: #f1f5f9;
    color: #475569;
    padding: 2px 6px;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 700;
    white-space: nowrap;
}

.persona-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    font-size: 0.76rem;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.persona-details span {
    display: flex;
    align-items: center;
    gap: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.persona-details span i {
    color: var(--primary);
    width: 14px;
}

.persona-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    border-top: 1px solid #f1f5f9;
    padding-top: 8px;
}

.btn-card-action {
    flex: 1;
    padding: 7px 8px;
    border-radius: 8px;
    border: none;
    font-size: 0.78rem;
    font-weight: 700;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    text-decoration: none;
}

.btn-card-action:active {
    transform: scale(0.96);
}

.btn-action-wa {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.btn-action-edit {
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}

.btn-action-del {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
    flex: 0 0 34px;
    padding: 7px 0;
}

/* Asistencias */
.asistencias-list {
    margin-top: 12px;
}

.asistencia-item {
    padding: 10px 12px;
    background: #f0fdf4;
    border-left: 3px solid var(--success);
    border-radius: 6px;
    font-size: 0.82rem;
    margin-bottom: 8px;
    color: var(--text-main);
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: white;
    display: flex;
    box-shadow: 0 -2px 15px rgba(0,0,0,0.05);
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom);
    border-top: 1px solid #e2e8f0;
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 1px 6px;
    color: #94a3b8;
    text-decoration: none;
    transition: all 0.15s;
}

.nav-item i {
    font-size: 1.15rem;
    margin-bottom: 3px;
}

.nav-item span {
    font-size: 0.68rem;
    font-weight: 600;
}

.nav-item.active {
    color: var(--primary);
}

.nav-item.active i {
    transform: scale(1.08);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 85px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: rgba(27, 67, 50, 0.95);
    color: white;
    padding: 10px 20px;
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 500;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 8px 25px rgba(0,0,0,0.25);
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 90%;
    text-align: center;
}

.toast.error {
    background: rgba(239, 68, 68, 0.95);
}

.toast.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}
