/* ================================================ */
/* PRecarga Chat - Styles                           */
/* ================================================ */

:root {
    --bg: #0B1120;
    --bg-secondary: #111827;
    --card: #1a2332;
    --border: #1e2d3d;
    --text: #E8ECF0;
    --text-gray: #6B7B8D;
    --green: #00D67E;
    --green-hover: #00b86c;
    --green-dim: rgba(0, 214, 126, 0.15);
    --cyan: #00B4D8;
    --cyan-dim: rgba(0, 180, 216, 0.15);
    --red: #EF4444;
    --yellow: #F59E0B;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}

.hidden { display: none !important; }
.sr-only {
    position: absolute; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0,0,0,0); border: 0;
}

/* --- Inputs & Buttons --- */
.input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-size: 0.95rem;
    outline: none;
    margin-bottom: 10px;
    transition: border-color 0.2s;
}
.input:focus { border-color: var(--green); }
.input::placeholder { color: var(--text-gray); }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}
.btn-primary {
    background: var(--green);
    color: #0B1120;
}
.btn-primary:hover { background: var(--green-hover); }
.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}
.btn-outline:hover { border-color: var(--green); color: var(--green); }
.btn-lg { width: 100%; padding: 14px; font-size: 1rem; }

/* --- Auth Error --- */
.auth-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--red);
    color: var(--red);
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
    margin-bottom: 12px;
    text-align: center;
}

/* --- Login Screen --- */
#loginScreen, #registerScreen {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}
.login-box {
    width: 100%;
    max-width: 380px;
    text-align: center;
}
.login-logo {
    margin-bottom: 6px;
}
.logo-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 4px;
}
.logo-text {
    font-size: 2rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--green), var(--cyan));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.login-subtitle {
    color: var(--text-gray);
    font-size: 0.9rem;
    margin-bottom: 24px;
}

/* --- Nav --- */
nav {
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    padding-left: max(8px, env(safe-area-inset-left));
    padding-right: max(8px, env(safe-area-inset-right));
}
.nav-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 56px;
    max-width: 900px;
    margin: 0 auto;
    padding: 0 16px;
}
.nav-brand {
    font-weight: 800;
    font-size: 1.15rem;
    color: var(--text);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 6px;
}
.nav-logo-icon { font-size: 1.3rem; }
.nav-brand-sub {
    font-weight: 500;
    color: var(--text-gray);
    font-size: 0.85rem;
}
.nav-right {
    display: flex;
    align-items: center;
    gap: 12px;
}
.nav-user {
    font-size: 0.85rem;
    color: var(--text-gray);
    font-weight: 500;
}
.nav-logout {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-gray);
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}
.nav-logout:hover { border-color: var(--red); color: var(--red); }

/* --- Chat Layout --- */
.chat-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 16px;
}
.chat-wrap {
    max-width: 700px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 80px);
}
.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
}
.chat-header h2 {
    margin: 0;
    font-size: 1.1rem;
    background: linear-gradient(135deg, var(--green), var(--cyan));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.chat-status {
    font-size: 0.75rem;
    color: var(--green);
    font-weight: 600;
}

/* --- Messages --- */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
.chat-messages::-webkit-scrollbar { width: 6px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.chat-bubble {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 14px;
    background: var(--card);
    border: 1px solid var(--border);
    align-self: flex-start;
    animation: bubbleIn 0.2s ease-out;
}
.chat-bubble.me {
    align-self: flex-end;
    background: #0d2847;
    border-color: #1a3a5c;
}
.chat-bubble.ruby {
    background: var(--green-dim);
    border-color: rgba(0, 214, 126, 0.3);
    border-left: 3px solid var(--green);
}
.chat-bubble-sender {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-gray);
    margin-bottom: 2px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.chat-bubble.me .chat-bubble-sender { color: var(--cyan); }
.chat-bubble.ruby .chat-bubble-sender { color: var(--green); }
.chat-bubble-text {
    font-size: 0.9rem;
    line-height: 1.5;
    word-break: break-word;
    white-space: pre-wrap;
}
.chat-bubble-time {
    font-size: 0.65rem;
    color: var(--text-gray);
    margin-top: 4px;
    text-align: right;
}

/* --- Typing indicator --- */
.chat-typing {
    padding: 6px 12px;
    font-size: 0.75rem;
    color: var(--green);
    font-style: italic;
    animation: fadeInOut 1.5s ease-in-out infinite;
}

/* --- Input Bar --- */
.chat-input-bar {
    display: flex;
    gap: 8px;
    padding: 10px 0;
    border-top: 1px solid var(--border);
}
.chat-input {
    flex: 1;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 16px;
    color: var(--text);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}
.chat-input:focus { border-color: var(--green); }
.chat-input::placeholder { color: var(--text-gray); }
.chat-send {
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 0.85rem;
    white-space: nowrap;
}

/* --- Toast --- */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 0.85rem;
    z-index: 1000;
    animation: toastIn 0.3s ease-out;
}
.toast.error { border-color: var(--red); color: var(--red); }

/* --- Animations --- */
@keyframes bubbleIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInOut {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}
@keyframes toastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(10px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* --- Responsive --- */
@media (max-width: 640px) {
    .chat-wrap { height: calc(100vh - 70px); }
    .chat-bubble { max-width: 90%; }
    .nav-user { display: none; }
    .chat-send { padding: 12px 16px; }
}
