/* =============================================
   CENTINELA - Estilos PWA
   ============================================= */

:root {
    --primary: #1a237e;
    --primary-dark: #0d1442;
    --primary-light: #3949ab;
    --accent: #ff6f00;
    --danger: #c62828;
    --danger-light: #ef5350;
    --success: #2e7d32;
    --warning: #f9a825;
    --text: #212121;
    --text-light: #757575;
    --bg: #f5f5f5;
    --card: #ffffff;
    --border: #e0e0e0;
    --shadow: 0 2px 8px rgba(0,0,0,0.15);
}

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

body {
    font-family: 'Roboto', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Pantallas */
.screen {
    display: none;
    flex-direction: column;
    min-height: 100vh;
}

.screen.active {
    display: flex;
}

/* Login */
.login-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 2rem;
    max-width: 400px;
    margin: 0 auto;
    width: 100%;
}

.logo {
    text-align: center;
    margin-bottom: 2rem;
}

.logo-icon {
    font-size: 64px;
    color: var(--primary);
}

.logo h1 {
    color: var(--primary);
    font-size: 2rem;
    font-weight: 700;
    margin-top: 0.5rem;
}

.logo p {
    color: var(--text-light);
    font-size: 0.9rem;
}

/* Formularios */
.form, .login-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text);
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 0.875rem 1rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
}

/* Botones */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--border);
    color: var(--text);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-block {
    width: 100%;
}

.btn-icon {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: rgba(255,255,255,0.1);
}

/* Header */
.header {
    background: var(--primary);
    color: white;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header h2 {
    flex: 1;
    font-size: 1.25rem;
    font-weight: 500;
}

.header-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
}

.header-info .material-icons {
    font-size: 36px;
}

.header-info div {
    display: flex;
    flex-direction: column;
}

.header-info small {
    opacity: 0.8;
    font-size: 0.75rem;
}

.header-danger {
    background: var(--danger);
}

/* Menú Principal */
.main-menu {
    flex: 1;
    padding: 1rem;
}

.menu-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    max-width: 500px;
    margin: 0 auto;
}

.menu-item {
    background: var(--card);
    border: none;
    border-radius: 12px;
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
}

.menu-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.menu-item .material-icons {
    font-size: 40px;
    color: var(--primary);
}

.menu-item span:last-child {
    font-size: 0.9rem;
    font-weight: 500;
    text-align: center;
    color: var(--text);
}

.menu-item-danger {
    background: var(--danger);
}

.menu-item-danger .material-icons,
.menu-item-danger span:last-child {
    color: white;
}

/* Footer */
.footer {
    text-align: center;
    padding: 1rem;
    color: var(--text-light);
}

/* Contenido de pantallas */
.screen-content {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
}

/* GPS Status */
.gps-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: #e3f2fd;
    border-radius: 8px;
    font-size: 0.9rem;
    color: #1565c0;
}

/* Listas */
.lista-items {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.lista-item {
    background: var(--card);
    padding: 1rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.lista-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.lista-item-header h4 {
    font-size: 0.95rem;
    font-weight: 500;
}

.lista-item-header small {
    color: var(--text-light);
    font-size: 0.8rem;
}

.lista-item p {
    font-size: 0.9rem;
    color: var(--text-light);
}

/* Divisor */
.section-divider {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-light);
    text-transform: uppercase;
    margin: 1.5rem 0 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

/* Info Card */
.info-card {
    background: var(--card);
    padding: 1rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
}

.info-card h3 {
    font-size: 0.9rem;
    color: var(--text-light);
    margin-bottom: 0.5rem;
}

.info-card p {
    font-size: 1.1rem;
    font-weight: 500;
}

/* Emergencia */
.screen-danger {
    background: #ffebee;
}

.emergencia-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    padding: 2rem;
}

.emergencia-warning {
    text-align: center;
    color: var(--danger);
}

.emergencia-warning .material-icons {
    font-size: 48px;
}

.emergencia-warning p {
    margin-top: 1rem;
    font-size: 0.95rem;
}

.btn-panico {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: var(--danger);
    border: 8px solid var(--danger-light);
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(198, 40, 40, 0.4);
    transition: transform 0.2s;
}

.btn-panico:active {
    transform: scale(0.95);
}

.btn-panico .material-icons {
    font-size: 64px;
}

.btn-panico span:last-child {
    font-size: 1rem;
    font-weight: 700;
}

/* Checkbox */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

/* Foto */
.photo-capture,
.photo-capture-login {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.foto-preview {
    max-width: 100%;
    max-height: 200px;
    object-fit: cover;
    border-radius: 8px;
    border: 2px solid var(--border);
}

.form-hint {
    color: var(--text-light);
    font-size: 0.8rem;
    margin-top: 0.25rem;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal-content {
    background: var(--card);
    padding: 1.5rem;
    border-radius: 12px;
    max-width: 400px;
    width: 100%;
}

.modal-content h3 {
    margin-bottom: 1rem;
}

.modal-content p {
    margin-bottom: 1.5rem;
    color: var(--text-light);
}

.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    z-index: 1001;
    animation: slideUp 0.3s ease;
}

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

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

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

/* Loading */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 2rem;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Utilities */
.hidden {
    display: none !important;
}

.error-message {
    background: #ffebee;
    color: var(--danger);
    padding: 1rem;
    border-radius: 8px;
    text-align: center;
    margin-top: 1rem;
}

/* Validación DNI en tiempo real */
.dni-validacion {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.85rem;
    margin-top: 0.25rem;
    transition: all 0.3s ease;
}

.dni-validacion.success {
    background: #e8f5e9;
    color: var(--success);
}

.dni-validacion.error {
    background: #ffebee;
    color: var(--danger);
}

.dni-validacion.loading {
    background: #e3f2fd;
    color: #1565c0;
}

.dni-validacion .dni-icon {
    font-size: 18px;
}

.dni-validacion #dni-nombre {
    flex: 1;
    font-weight: 500;
}

/* =============================================
   BANNER INSTALACIÓN PWA
   ============================================= */

.install-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
    color: white;
    padding: 15px 20px;
    z-index: 1001;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.3);
    animation: slideUpBanner 0.4s ease-out;
}

.install-banner.hidden {
    display: none;
}

.install-content {
    display: flex;
    align-items: center;
    gap: 15px;
    max-width: 500px;
    margin: 0 auto;
}

.install-icon {
    width: 50px;
    height: 50px;
    background: var(--accent);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.install-icon .material-icons {
    font-size: 28px;
    color: white;
}

.install-text {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.install-text strong {
    font-size: 16px;
    margin-bottom: 3px;
}

.install-text span {
    font-size: 12px;
    color: rgba(255,255,255,0.8);
}

.install-banner .btn {
    padding: 10px 20px;
    font-size: 14px;
    white-space: nowrap;
}

.btn-close-banner {
    background: none;
    border: none;
    color: rgba(255,255,255,0.6);
    font-size: 24px;
    cursor: pointer;
    padding: 5px;
    line-height: 1;
}

.btn-close-banner:hover {
    color: white;
}

@keyframes slideUpBanner {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

/* Responsive */
@media (max-width: 400px) {
    .menu-grid {
        grid-template-columns: 1fr;
    }

    .btn-panico {
        width: 160px;
        height: 160px;
    }

    .btn-panico .material-icons {
        font-size: 48px;
    }

    .install-content {
        flex-wrap: wrap;
    }

    .install-banner .btn {
        flex: 1;
    }
}
