/* ========================================
   MEMORIAL — Base styles
   Reset, tipografia, componentes base
   ======================================== */

/* Reset */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }

html {
    font-family: var(--font-family);
    font-size: 16px;
    line-height: var(--line-height-normal);
    color: var(--color-text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    background: var(--color-bg);
    min-height: 100dvh;
}

/* Gestos y touch */
* { touch-action: manipulation; }
a, button, input, select, textarea { -webkit-tap-highlight-color: transparent; }
:focus:not(:focus-visible) { outline: none; }
:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }

/* Senior layout override */
.layout-senior { font-size: var(--font-size-lg); line-height: var(--line-height-relaxed); }

/* Headings */
.heading-page    { font-size: var(--font-size-2xl); font-weight: var(--font-weight-bold); }
.heading-section { font-size: var(--font-size-xl);  font-weight: var(--font-weight-semibold); }
.heading-card    { font-size: var(--font-size-lg);  font-weight: var(--font-weight-semibold); }

@media (min-width: 768px) {
    .heading-page    { font-size: var(--font-size-3xl); }
    .heading-section { font-size: var(--font-size-2xl); }
}

/* ── Botones ── */
.btn-memorial {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-height: var(--touch-comfortable);
    padding: var(--space-3) var(--space-6);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-semibold);
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-base);
    -webkit-tap-highlight-color: transparent;
    text-decoration: none;
    width: 100%;
    font-family: var(--font-family);
}
@media (min-width: 576px) { .btn-memorial { width: auto; } }

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: var(--shadow-button);
}
.btn-primary:hover { opacity: 0.9; box-shadow: var(--shadow-md); }
.btn-primary:active { transform: scale(0.98); box-shadow: none; }

.btn-secondary {
    background: var(--color-bg-elevated);
    color: var(--color-text-primary);
    border: 1px solid var(--color-border);
}
.btn-secondary:hover { background: var(--color-divider); }

.btn-google {
    background: white;
    color: var(--color-text-primary);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
}
.btn-google:hover { background: var(--color-bg); box-shadow: var(--shadow-md); }

.btn-ghost {
    background: transparent;
    color: var(--color-primary);
    border: none;
}
.btn-ghost:hover { background: var(--color-bg-elevated); }

.layout-senior .btn-memorial {
    min-height: var(--touch-senior);
    font-size: var(--font-size-lg);
    padding: var(--space-4) var(--space-8);
}

/* ── Cards ── */
.card-memorial {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    padding: var(--space-5);
    box-shadow: var(--shadow-card);
    transition: box-shadow var(--transition-base);
}
.card-memorial:hover { box-shadow: var(--shadow-md); }

.card-form {
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
    padding: var(--space-8) var(--space-6);
}
@media (max-width: 575px) {
    .card-form {
        border: none;
        box-shadow: none;
        border-radius: 0;
        padding: var(--space-6) var(--space-4);
    }
}

/* ── Separadores ── */
.divider-text {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    margin: var(--space-6) 0;
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
}
.divider-text::before,
.divider-text::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--color-divider);
}

/* ── Skeleton loaders ── */
.skeleton {
    background: linear-gradient(90deg, var(--color-bg-elevated) 25%, var(--color-divider) 50%, var(--color-bg-elevated) 75%);
    background-size: 200% 100%;
    animation: skeleton-pulse 1.5s ease infinite;
    border-radius: var(--radius-sm);
}
.skeleton-text   { height: 1em; margin-bottom: var(--space-2); }
.skeleton-title  { height: 1.5em; width: 60%; margin-bottom: var(--space-4); }
.skeleton-button { height: var(--touch-comfortable); border-radius: var(--radius-lg); }
.skeleton-avatar { width: 40px; height: 40px; border-radius: var(--radius-full); }

@keyframes skeleton-pulse {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ── Spinner ── */
.spinner-sm {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Empty state ── */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: var(--space-12) var(--space-6);
    color: var(--color-text-secondary);
}
.empty-state-icon { margin-bottom: var(--space-4); opacity: 0.4; }
.empty-state-title {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-primary);
    margin-bottom: var(--space-2);
}
.empty-state-text { margin-bottom: var(--space-6); max-width: 300px; }

/* ── Transicion pagina ── */
.page-content { animation: fadeIn var(--transition-base); }
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Bottom Sheet ── */
.bottom-sheet-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: var(--z-modal-backdrop);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-base);
}
.bottom-sheet-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

.bottom-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--color-bg-card);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    z-index: var(--z-modal);
    transform: translateY(100%);
    transition: transform var(--transition-slow);
    padding: var(--space-4);
    padding-bottom: calc(var(--space-8) + env(safe-area-inset-bottom));
    max-height: 70vh;
    overflow-y: auto;
    box-shadow: var(--shadow-elevated);
}
.bottom-sheet.active {
    transform: translateY(0);
}

.bottom-sheet-handle {
    width: 36px;
    height: 4px;
    background: var(--color-divider);
    border-radius: var(--radius-full);
    margin: 0 auto var(--space-4);
}

.bottom-sheet-title {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-primary);
    margin-bottom: var(--space-4);
    padding: 0 var(--space-2);
}

.bottom-sheet-options {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.bottom-sheet-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-2);
    min-height: var(--touch-comfortable);
    border-radius: var(--radius-md);
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-size: var(--font-size-base);
    color: var(--color-text-primary);
    transition: background var(--transition-fast);
}
.bottom-sheet-item:hover,
.bottom-sheet-item:active {
    background: var(--color-bg-elevated);
}
.bottom-sheet-item--danger {
    color: var(--color-danger);
}

/* ── Toasts ── */
.toast-success,
.toast-error {
    position: fixed;
    top: var(--space-4);
    left: 50%;
    transform: translateX(-50%);
    padding: var(--space-3) var(--space-6);
    border-radius: var(--radius-lg);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    z-index: var(--z-toast);
    transition: opacity var(--transition-base);
    max-width: 90%;
    text-align: center;
}
.toast-success {
    background: var(--color-success);
    color: white;
}
.toast-error {
    background: var(--color-danger);
    color: white;
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* Gestos y touch */
* {
    touch-action: manipulation;
}

/* iOS PWA: los inputs necesitan su comportamiento nativo intacto */
input, textarea, select {
    touch-action: auto;
    user-select: text;
    -webkit-user-select: text;
}

a, button, input, select, textarea {
    -webkit-tap-highlight-color: transparent;
}