/**
 * Higopico Aula - Estilos Móviles Táctiles Oficiales
 * Mobile-First: Optimizado para teléfonos (90%) y tablets (10%)
 */

:root {
    --bg-app: #f8fafc;
    --bg-card: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --primary: #0284c7;
    --primary-dark: #0369a1;
    --primary-light: #e0f2fe;
    --accent: #10b981;
    --danger: #ef4444;
    --border: #e2e8f0;
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-full: 9999px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-app);
    color: var(--text-primary);
    line-height: 1.4;
    padding-bottom: calc(70px + var(--safe-bottom));
    min-height: 100vh;
    touch-action: manipulation;
}

/* ==========================================================================
   Cabecera Superior Móvil
   ========================================================================== */
.app-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: #ffffff;
    border-bottom: 1px solid var(--border);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 58px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

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

.brand-logo {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    object-fit: contain;
}

.brand-title {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.brand-subtitle {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

.btn-header-push {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
    background: #ffffff;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.btn-header-push.active {
    background: #dcfce7;
    border-color: #86efac;
    color: #15803d;
}

.btn-header-push.active::after {
    content: '';
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
}

.aula-badge-select {
    padding: 6px 12px;
    border-radius: var(--radius-full);
    background: var(--primary-light);
    color: var(--primary-dark);
    border: none;
    font-size: 0.82rem;
    font-weight: 700;
    outline: none;
    cursor: pointer;
    max-width: 140px;
}

/* ==========================================================================
   Navegación Inferior Fija (Bottom Navigation Bar)
   ========================================================================== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 50;
    background: #ffffff;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    padding: 8px 6px calc(8px + var(--safe-bottom));
    box-shadow: 0 -2px 10px rgba(0,0,0,0.03);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 600;
    gap: 3px;
    flex: 1;
    cursor: pointer;
    position: relative;
    padding: 4px 0;
    transition: color 0.15s;
}

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

.nav-icon {
    font-size: 1.25rem;
    position: relative;
}

.nav-badge-count {
    position: absolute;
    top: -4px;
    right: -8px;
    background: var(--danger);
    color: #ffffff;
    font-size: 0.65rem;
    font-weight: 800;
    padding: 1px 5px;
    border-radius: 10px;
    min-width: 16px;
    text-align: center;
}

/* ==========================================================================
   Contenedor Principal de Vistas
   ========================================================================== */
.app-view {
    padding: 12px 14px;
    max-width: 720px;
    margin: 0 auto;
}

.view-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.view-title {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-primary);
}

.btn-primary-action {
    background: var(--primary);
    color: #ffffff;
    border: none;
    border-radius: var(--radius-full);
    padding: 8px 16px;
    font-size: 0.85rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}

/* ==========================================================================
   Lista de Chats de Mensajería
   ========================================================================== */
.chat-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-card {
    background: #ffffff;
    border-radius: var(--radius-md);
    padding: 12px 14px;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.1s;
    box-shadow: var(--shadow-sm);
}

.chat-card:active {
    transform: scale(0.99);
}

.chat-avatar {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-full);
    background: #e0f2fe;
    color: #0284c7;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.15rem;
    flex-shrink: 0;
}

.chat-body {
    flex: 1;
    min-width: 0;
}

.chat-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 3px;
}

.chat-name {
    font-size: 0.96rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.chat-snippet-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.chat-snippet {
    font-size: 0.84rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-unread-badge {
    background: var(--danger);
    color: #ffffff;
    font-size: 0.72rem;
    font-weight: 800;
    padding: 2px 7px;
    border-radius: var(--radius-full);
}

/* ==========================================================================
   Vista de Conversación Abierta (Chat Completo)
   ========================================================================== */
.conversation-screen {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #ffffff;
    z-index: 100;
    flex-direction: column;
}

.conv-header {
    background: #ffffff;
    border-bottom: 1px solid var(--border);
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    height: 60px;
    flex-shrink: 0;
}

.btn-conv-back {
    background: none;
    border: none;
    font-size: 1.3rem;
    color: var(--primary);
    cursor: pointer;
    padding: 4px;
}

.conv-info {
    flex: 1;
    min-width: 0;
}

.conv-title {
    font-size: 0.98rem;
    font-weight: 800;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.conv-messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    background: #f1f5f9;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.msg-bubble-wrap {
    display: flex;
    flex-direction: column;
    max-width: 82%;
}

.msg-bubble-wrap.sent {
    align-self: flex-end;
}

.msg-bubble-wrap.received {
    align-self: flex-start;
}

.msg-bubble {
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 0.92rem;
    line-height: 1.4;
    word-break: break-word;
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

.msg-bubble-wrap.sent .msg-bubble {
    background: #0284c7;
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.msg-bubble-wrap.received .msg-bubble {
    background: #ffffff;
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--border);
}

.msg-meta {
    font-size: 0.68rem;
    margin-top: 3px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.msg-bubble-wrap.sent .msg-meta {
    color: #bae6fd;
    justify-content: flex-end;
}

.msg-bubble-wrap.received .msg-meta {
    color: var(--text-muted);
}

.conv-input-bar {
    background: #ffffff;
    border-top: 1px solid var(--border);
    padding: 10px 14px calc(10px + var(--safe-bottom));
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.conv-textarea {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    padding: 10px 16px;
    font-size: 0.92rem;
    outline: none;
    max-height: 90px;
    resize: none;
    font-family: inherit;
}

.conv-textarea:focus {
    border-color: var(--primary);
}

.btn-conv-send {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-full);
    background: var(--primary);
    color: #ffffff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    cursor: pointer;
    flex-shrink: 0;
}

/* ==========================================================================
   Pantalla de Login
   ========================================================================== */
.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: #0f172a;
}

.login-card {
    background: #ffffff;
    border-radius: var(--radius-lg);
    padding: 28px 24px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
}

.login-brand {
    text-align: center;
    margin-bottom: 22px;
}

.login-brand h1 {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text-primary);
}

.login-brand p {
    font-size: 0.82rem;
    color: var(--text-secondary);
}

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

.form-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
}

.form-input:focus {
    border-color: var(--primary);
}

.btn-login {
    width: 100%;
    background: var(--primary);
    color: #ffffff;
    border: none;
    border-radius: var(--radius-md);
    padding: 14px;
    font-size: 0.96rem;
    font-weight: 700;
    cursor: pointer;
    margin-top: 8px;
    box-shadow: var(--shadow-md);
}

/* ==========================================================================
   Modal Táctil Bottom Sheet (Nuevo Mensaje)
   ========================================================================== */
.bottom-sheet-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    z-index: 80;
    backdrop-filter: blur(4px);
}

.bottom-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #ffffff;
    border-top-left-radius: 24px;
    border-top-right-radius: 24px;
    padding: 20px 18px calc(24px + var(--safe-bottom));
    z-index: 81;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 -10px 30px rgba(0,0,0,0.15);
    display: none;
}

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

.bottom-sheet-title {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text-primary);
}

.btn-close-sheet {
    background: #f1f5f9;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 1rem;
    cursor: pointer;
}