:root {
    --primary: #00A99D;
    --primary-dark: #008f84;
    --secondary: #1A3050;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --pending: #94a3b8;
    --bg: #E1F1F6;
    --card: #ffffff;
    --text: #1A3050;
    --text-light: #64748b;
    --radius: 16px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.5;
    overflow-x: hidden;
    user-select: none;
}

#app {
    max-width: 500px;
    margin: 0 auto;
    min-height: 100vh;
    position: relative;
    background: var(--bg);
}

.screen {
    display: none;
    padding: 16px;
    min-height: 100vh;
    animation: fadeIn 0.3s ease;
}

.screen.active {
    display: block;
}

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

/* Header */
header {
    background: var(--primary);
    color: white;
    padding: 20px;
    margin-bottom: 20px;
    border-bottom-left-radius: 24px;
    border-bottom-right-radius: 24px;
    position: relative;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.header-content {
    display: flex;
    flex-direction: column;
}

header h2 {
    font-size: 1.5rem;
    font-weight: 800;
}

#user-name {
    font-size: 0.875rem;
    color: rgba(255,255,255,0.8);
}

.selection-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    gap: 10px;
}

.date-selector {
    flex: 1;
    max-width: 160px;
}

#route-date-picker {
    width: 100%;
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    background: white;
    color: var(--text);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    outline: none;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

#logout-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Utils */
.badge {
    padding: 4px 12px;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--primary);
    color: white;
    display: inline-block;
}

.hidden { display: none !important; }

/* Buttons */
.bg-success { background-color: var(--presente) !important; color: white !important; }
.bg-primary { background-color: var(--primary) !important; color: white !important; }

.btn {
    border: none;
    border-radius: var(--radius);
    padding: 12px 20px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.btn-lg {
    padding: 20px;
    font-size: 1.125rem;
}

.btn-primary { background: var(--primary); color: white; }
.btn-success { background: var(--success) !important; color: white; }
.btn-danger { background: var(--danger) !important; color: white; }
.btn-warning { background: var(--warning); color: white; }
.btn-block { width: 100%; display: block; }

.btn.active {
    transform: scale(0.95);
    box-shadow: 0 0 15px rgba(0,0,0,0.3);
    border: 3px solid white;
    filter: brightness(1.1);
    z-index: 2;
}

.btn-large {
    padding: 18px;
    font-size: 1.1rem;
    font-weight: 800;
}

.btn-group-inactive {
    opacity: 0.3;
    filter: grayscale(0.8);
    transform: scale(0.9);
}

.btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.btn-icon {
    background: none;
    border: none;
    font-size: 1.5rem;
    padding: 8px;
}

/* Grid */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 12px;
}

/* Login */
.login-container {
    padding: 60px 20px;
    text-align: center;
}

.app-logo {
    width: 140px;
    height: auto;
    margin-bottom: 24px;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.1));
}

h1 {
    font-size: 2rem;
    font-weight: 800;
    color: var(--secondary);
    margin-bottom: 4px;
}

.subtitle {
    font-size: 1rem;
    color: var(--primary);
    font-weight: 600;
    margin-bottom: 32px;
}

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

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 6px;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius);
    font-size: 1rem;
}

.error-msg {
    color: var(--danger);
    font-size: 0.875rem;
    margin-top: 12px;
}

/* List */
.list {
    list-style: none;
    margin-top: 16px;
}

.list-item {
    background: var(--card);
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 12px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -1px rgba(0,0,0,0.03);
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s;
    border-left: 5px solid transparent;
}

.status-border-pendiente { border-left-color: var(--pending); }
.status-border-presente { border-left-color: var(--success); }
.status-border-ausente { border-left-color: var(--danger); }
.status-border-curso { border-left-color: var(--warning); }

.bg-warning { background-color: var(--warning) !important; color: white !important; }

.pulse {
    animation: pulse-animation 2s infinite;
}

@keyframes pulse-animation {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7); }
    70% { transform: scale(1.05); box-shadow: 0 0 0 10px rgba(245, 158, 11, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}

.avatar {
    width: 44px;
    height: 44px;
    background: #E1F1F6;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.875rem;
    color: var(--primary);
    flex-shrink: 0;
}

.concurrente-main {
    flex: 1;
}

.concurrente-name {
    font-weight: 700;
    font-size: 1rem;
    color: #0f172a;
}

.concurrente-addr {
    font-size: 0.8125rem;
    color: var(--text-light);
    display: flex;
    align-items: center;
    gap: 4px;
}

.icon-small { font-size: 0.75rem; }

.status-badge {
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.625rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-pendiente { background: #f1f5f9; color: #64748b; }
.badge-presente { background: #dcfce7; color: #166534; }
.badge-ausente { background: #fee2e2; color: #991b1b; }
.badge-curso { background: #fef3c7; color: #92400e; }

/* Details */
.concurrente-info-card {
    background: var(--card);
    padding: 20px;
    border-radius: var(--radius);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    margin-bottom: 20px;
}

.maps-btn {
    display: block;
    margin-top: 12px;
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.875rem;
}

.checklist-card {
    background: var(--card);
    padding: 20px;
    border-radius: var(--radius);
    margin-top: 24px;
}

.checklist-items {
    margin: 12px 0;
}

.check-item {
    display: block;
    padding: 10px 0;
    border-bottom: 1px solid #f1f5f9;
    font-size: 1rem;
}

.check-item input {
    margin-right: 12px;
    transform: scale(1.2);
}

textarea {
    width: 100%;
    height: 80px;
    padding: 12px;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius);
    margin-top: 12px;
    font-family: inherit;
}

/* Sync Banner */
.sync-banner {
    background: var(--warning);
    color: white;
    padding: 8px;
    text-align: center;
    font-size: 0.75rem;
    border-radius: 8px;
    margin-bottom: 12px;
}

/* Spinner */
.spinner {
    border: 4px solid rgba(0, 0, 0, 0.1);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border-left-color: var(--primary);
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.mt-4 { margin-top: 1.5rem; }

/* Trip Controls */
.trip-header {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 10px;
}

.btn-text {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 0.85rem;
    font-weight: 600;
    padding: 5px 10px;
    cursor: pointer;
}

.trip-controls {
    padding: 16px;
    background: var(--card);
    border-radius: var(--radius);
    margin-bottom: 20px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
}

.trip-active-banner {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 12px;
    background: #dcfce7;
    color: #166534;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.875rem;
}

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

.empty-state p {
    font-size: 1.1rem;
    line-height: 1.5;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 12px 24px;
    border-radius: 99px;
    color: white;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 9999;
    transition: transform 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
    white-space: nowrap;
}

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

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

/* Custom Checkbox */
.check-item input:checked + span {
    color: var(--primary);
    font-weight: 600;
}

/* Custom Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(26, 48, 80, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

.modal-card {
    background: white;
    width: 100%;
    max-width: 340px;
    padding: 30px 24px;
    border-radius: 24px;
    text-align: center;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    animation: slideUp 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

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

.modal-icon {
    font-size: 3rem;
    margin-bottom: 16px;
}

.modal-card h3 {
    color: var(--secondary);
    font-size: 1.25rem;
    font-weight: 800;
    margin-bottom: 8px;
}

.modal-card p {
    color: var(--text-light);
    font-size: 0.95rem;
    margin-bottom: 24px;
    line-height: 1.4;
}

.modal-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.btn-secondary {
    background: #f1f5f9;
    color: #475569;
}

/* Hover effects for list */
.list-item:active {
    transform: scale(0.98);
    background: #f1f5f9;
}

main {
    padding-bottom: 80px; /* Espacio para nav */
}

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: space-around;
    padding: 10px 0;
    border-top: 1px solid #e2e8f0;
    box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.05);
    z-index: 1000;
}

.nav-item {
    background: none;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    color: #94a3b8;
    font-size: 0.7rem;
    font-weight: 600;
    width: 33%;
}

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

.nav-icon {
    font-size: 1.4rem;
    margin-bottom: 2px;
    position: relative;
}

.badge-count {
    position: absolute;
    top: -5px;
    right: -10px;
    background: #ef4444;
    color: white;
    font-size: 0.6rem;
    padding: 1px 5px;
    border-radius: 10px;
    border: 2px solid white;
}

.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }

.avatar-img {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
    margin-right: 15px;
    border: 2px solid var(--primary);
}

.btn-link-maps {
    display: inline-block;
    color: var(--primary);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 700;
    padding: 6px 12px;
    background: rgba(0, 168, 150, 0.1);
    border-radius: 8px;
    transition: all 0.2s;
}

.btn-link-maps:hover {
    background: var(--primary);
    color: white;
}

.concurrente-actions {
    display: flex;
    gap: 10px;
}

/* --- Nuevas Funcionalidades Premium --- */

/* SOS Button */
.btn-sos {
    position: fixed;
    bottom: 85px;
    left: 20px;
    width: 50px;
    height: 50px;
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 50%;
    font-weight: bold;
    font-size: 0.7rem;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.4);
    z-index: 1000;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulse-sos 2s infinite;
    opacity: 0.8;
    transition: opacity 0.2s;
}
.btn-sos:active { opacity: 1; transform: scale(1.1); }

@keyframes pulse-sos {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
    70% { transform: scale(1.1); box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* Online Indicator */
.online-dot {
    width: 12px;
    height: 12px;
    background: #22c55e;
    border-radius: 50%;
    margin-right: 10px;
    display: inline-block;
    border: 2px solid white;
}
.online-dot.offline { background: #94a3b8; }

/* Signature Card */
.signature-card {
    background: white;
    padding: 16px;
    border-radius: var(--radius);
    margin-top: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.signature-card h4 { margin-bottom: 12px; color: var(--text-light); font-size: 0.9rem; }
.canvas-container {
    border: 2px dashed #e2e8f0;
    border-radius: 8px;
    background: #f8fafc;
    height: 150px;
    position: relative;
    overflow: hidden;
}
#signature-pad {
    width: 100%;
    height: 100%;
    cursor: crosshair;
}

/* Contrast Mode */
body.contrast-mode {
    --bg: #000000;
    --card: #1a1a1a;
    --text: #ffffff;
    --text-light: #cccccc;
    --primary: #ffffff;
    --primary-dark: #eeeeee;
}
body.contrast-mode header { background: #000000; border: 2px solid white; }
body.contrast-mode .btn-primary { background: white; color: black; font-weight: 900; }
body.contrast-mode .list-item { border: 2px solid #444; background: #111; }
body.contrast-mode .nav-item.active { background: white; color: black; }

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

/* Stats Banner */
.stats-banner {
    display: flex;
    justify-content: space-around;
    background: white;
    padding: 12px;
    border-radius: var(--radius);
    margin: 15px 0;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    border: 1px solid #e2e8f0;
}
.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}
.stat-val { font-weight: 800; font-size: 1.2rem; color: var(--primary); }
.stat-lab { font-size: 0.7rem; color: var(--text-light); text-transform: uppercase; }

/* Phone Link */
.btn-link-phone {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f0f9ff;
    color: #0369a1;
    text-decoration: none;
    padding: 8px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid #bae6fd;
}
.btn-link-phone:hover { background: #e0f2fe; }

.btn-link-maps, .btn-link-call, .btn-link-wa {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 700;
    text-decoration: none;
    transition: all 0.2s;
}

.btn-link-maps { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.btn-link-call { background: #f0f9ff; color: #0369a1; border: 1px solid #bae6fd; }
.btn-link-wa { background: #f0fdf4; color: #166534; border: 1px solid #dcfce7; }

.btn-link-maps:active { background: #dcfce7; }
.btn-link-call:active { background: #e0f2fe; }
.btn-link-wa:active { background: #bbf7d0; }
