:root {
    --primary: #ff4d6d;
    --primary-gradient: linear-gradient(135deg, #ff4d6d 0%, #ff758f 100%);
    --secondary: #7209b7;
    --bg: #08080a;
    --card: rgba(21, 21, 26, 0.7);
    --text: #ffffff;
    --text-dim: rgba(255, 255, 255, 0.6);
    --glass: rgba(255, 255, 255, 0.03);
    --border: rgba(255, 255, 255, 0.08);
    --surface: #121217;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* Fix backdrop-filter compatibility */
.glass-effect {
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    height: 100%;
    width: 100%;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    min-height: -webkit-fill-available;
    line-height: 1.6;
    background-image:
        radial-gradient(circle at 0% 0%, rgba(255, 77, 109, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 100% 100%, rgba(114, 9, 183, 0.05) 0%, transparent 50%);
    background-attachment: fixed;
}

/* Background Blobs */
.blob {
    position: fixed;
    width: 600px;
    height: 600px;
    background: var(--primary-gradient);
    filter: blur(100px);
    border-radius: 50%;
    z-index: -1;
    opacity: 0.12;
    pointer-events: none;
    animation: blobMove 20s infinite alternate ease-in-out;
}

.blob-1 {
    top: -10%;
    left: -10%;
}

.blob-2 {
    bottom: -10%;
    right: -10%;
    background: var(--secondary);
    animation-delay: -10s;
}

@keyframes blobMove {
    from {
        transform: translate(0, 0) rotate(0deg);
    }

    to {
        transform: translate(100px, 50px) rotate(15deg);
    }
}

/* Layout Containers */
.container {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    padding: calc(1rem + var(--safe-top)) 1rem calc(1rem + var(--safe-bottom));
}

.app-container {
    width: 100%;
    max-width: 100%;
    /* Mobile first: full width */
    margin: 0 auto;
    padding: calc(1rem + var(--safe-top)) 1rem calc(6rem + var(--safe-bottom));
    /* Massive bottom padding for nav */
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

/* Compact Card for Mobile Lists */
.compact-card {
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 1rem;
    margin-bottom: 0.8rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.compact-card .icon {
    font-size: 1.5rem;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
}

.compact-card .content {
    flex: 1;
    text-align: left;
}

.compact-card h3 {
    font-size: 1rem;
    font-weight: 700;
    margin: 0;
}

.compact-card p {
    font-size: 0.8rem;
    color: var(--text-dim);
    margin: 0;
    line-height: 1.3;
}

.auth-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 1.5rem;
    position: relative;
    width: 100%;
}

/* Common Button Styles */
.btn-main {
    padding: 1.1rem 1.8rem;
    background: var(--primary-gradient);
    color: white;
    text-decoration: none;
    border-radius: 18px;
    font-weight: 700;
    transition: all 0.3s cubic-bezier(0.23, 1, 0.32, 1);
    border: none;
    cursor: pointer;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    box-shadow: 0 10px 20px -10px rgba(255, 77, 109, 0.5);
    -webkit-user-select: none;
    user-select: none;
}

.btn-main:active {
    transform: scale(0.96);
}

.btn-glass {
    background: var(--glass) !important;
    border: 1px solid var(--border) !important;
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    color: white;
}

.btn-danger {
    background: rgba(239, 68, 68, 0.1) !important;
    color: #ef4444 !important;
    border: 1px solid rgba(239, 68, 68, 0.2) !important;
}

/* Form Container and Cards */
.premium-card {
    background: var(--card);
    padding: 2.5rem 2rem;
    border-radius: 32px;
    width: 100%;
    max-width: 420px;
    border: 1px solid var(--border);
    -webkit-backdrop-filter: blur(30px);
    backdrop-filter: blur(30px);
    box-shadow: 0 40px 80px -20px rgba(0, 0, 0, 0.5);
    animation: premiumFadeIn 0.8s cubic-bezier(0.16, 1, 0.3, 1);
    margin-bottom: 2rem;
}

.glass-card {
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 1.5rem;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    margin-bottom: 1.5rem;
}

@keyframes premiumFadeIn {
    from {
        opacity: 0;
        transform: translateY(40px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

h1 {
    font-size: 2.2rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    text-align: center;
    letter-spacing: -0.02em;
    color: white;
}

.primary-text-gradient {
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--text-dim);
    text-align: center;
    margin-bottom: 2rem;
    font-size: 1rem;
    font-weight: 500;
}

/* Inputs */
.input-group {
    margin-bottom: 1.5rem;
    text-align: left;
}

.input-group label {
    display: block;
    margin-bottom: 0.6rem;
    color: var(--text-dim);
    font-size: 0.85rem;
    font-weight: 600;
    padding-left: 4px;
}

.input-group input,
.input-glass {
    width: 100%;
    padding: 1.1rem 1.4rem;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 1rem;
    outline: none;
    transition: all 0.3s ease;
    -webkit-appearance: none;
    appearance: none;
}

.input-group input:focus {
    background: rgba(255, 77, 109, 0.05);
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(255, 77, 109, 0.1);
}

/* Unified Role Selector (Login) */
.role-selector-container {
    background: rgba(255, 255, 255, 0.05);
    padding: 6px;
    border-radius: 20px;
    display: flex;
    position: relative;
    margin: 0 auto 2rem;
    width: 100%;
    max-width: 280px;
    border: 1px solid var(--border);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    z-index: 10;
}

.role-option {
    flex: 1;
    padding: 12px 0;
    text-align: center;
    font-weight: 700;
    color: var(--text-dim);
    cursor: pointer;
    z-index: 2;
    transition: color 0.3s ease;
    font-size: 0.85rem;
    -webkit-user-select: none;
    user-select: none;
}

.role-option.active {
    color: white;
}

.selector-bg {
    position: absolute;
    top: 6px;
    left: 6px;
    width: calc(50% - 6px);
    height: calc(100% - 12px);
    background: var(--primary-gradient);
    border-radius: 16px;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 4px 15px rgba(255, 77, 109, 0.3);
    z-index: 1;
}

[data-role="blinder"] .selector-bg {
    transform: translateX(100%);
}

/* Content Grid Stack */
.content-sections-wrapper {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    width: 100%;
}

.content-section {
    grid-column: 1;
    grid-row: 1;
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.content-section.hidden {
    display: none !important;
}


/* --- DASHBOARD & INTERFACE STYLES (Restored) --- */

.nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.nav-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.settings-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.2s;
    color: white;
}

.settings-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: rotate(45deg);
}

/* Tabs */
.tabs {
    background: rgba(0, 0, 0, 0.2);
    padding: 0.3rem;
    border-radius: 16px;
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border);
}

.tab-btn {
    flex: 1;
    padding: 0.8rem;
    border: none;
    background: transparent;
    /* Default transparent */
    color: var(--text-dim);
    font-weight: 600;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.tab-btn.active {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* Room Cards */
.room-card {
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 1.2rem;
    margin-bottom: 1rem;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s;
}

.room-card:active {
    transform: scale(0.98);
}

.room-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.room-names {
    font-weight: 700;
    font-size: 1.05rem;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 65%;
}

.badge {
    padding: 0.3rem 0.8rem;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-desconectado {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-dim);
    border: 1px solid var(--border);
}

.badge-activo {
    background: rgba(74, 222, 128, 0.1);
    color: #4ade80;
    border: 1px solid rgba(74, 222, 128, 0.2);
    box-shadow: 0 0 10px rgba(74, 222, 128, 0.1);
}

.badge-aconectado,
.badge-bconectado {
    background: rgba(59, 130, 246, 0.1);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.2);
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.1);
}

/* Link Pills */
.link-pills {
    display: flex;
    gap: 0.8rem;
}

.pill {
    flex: 1;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 0.8rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.pill span:first-child {
    font-size: 0.75rem;
    color: var(--text-dim);
    text-transform: uppercase;
    font-weight: 700;
}

.pill span:last-child {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary);
}

.pill:active {
    background: rgba(255, 77, 109, 0.05);
}

.pill.used {
    opacity: 0.5;
    background: transparent;
}

.glass-dashed {
    border: 1px dashed var(--border);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.02);
}


/* --- MODAL (Missing in previous version!) --- */
.modal {
    display: none;
    position: fixed;
    z-index: 9000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    /* Dark overlay */
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal .premium-card {
    margin: 0;
    max-width: 400px;
    width: 100%;
    position: relative;
    animation: modalPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modalPop {
    from {
        transform: scale(0.9) translateY(20px);
        opacity: 0;
    }

    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

.close-modal {
    position: absolute;
    top: 15px;
    right: 25px;
    font-size: 2rem;
    color: var(--text-dim);
    cursor: pointer;
    line-height: 1;
    padding: 10px;
    /* larger click area */
    z-index: 10;
}


/* Utilities */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.w-full {
    width: 100% !important;
}

.mt-1 {
    margin-top: 1rem;
}

.mt-2 {
    margin-top: 2rem;
}

.mb-1 {
    margin-bottom: 1rem;
}

.mb-2 {
    margin-bottom: 2rem;
}

.p-1 {
    padding: 1rem;
}

.p-2 {
    padding: 2rem;
}

.p-3 {
    padding: 3rem;
}

.pt-1 {
    padding-top: 1rem;
}

.px-2 {
    padding-left: 2rem;
    padding-right: 2rem;
}

.fs-small {
    font-size: 0.8rem;
}

.fs-h1 {
    font-size: 1.8rem;
}

.font-800 {
    font-weight: 800;
}

.text-dim {
    color: var(--text-dim) !important;
}

.text-success {
    color: #4ade80 !important;
}

.hidden {
    display: none !important;
}

.glass-border-top {
    border-top: 1px solid var(--border) !important;
}

.glass-border-bottom {
    border-bottom: 1px solid var(--border) !important;
}

.max-auto {
    margin: 0 auto !important;
}

.max-w-400 {
    max-width: 400px !important;
}

.hero-emoji-main {
    font-size: 4rem;
    margin-bottom: 2rem;
    text-align: center;
}

/* Empty State Animation */
@keyframes floatEmpty {
    0% {
        transform: translateY(0px) rotate(0deg);
        opacity: 0.7;
    }

    50% {
        transform: translateY(-15px) rotate(5deg);
        opacity: 1;
    }

    100% {
        transform: translateY(0px) rotate(0deg);
        opacity: 0.7;
    }
}

.empty-state-icon {
    font-size: 4rem;
    display: inline-block;
    animation: floatEmpty 3s ease-in-out infinite;
    margin-bottom: 1rem;
    filter: drop-shadow(0 0 10px rgba(255, 77, 109, 0.3));
}

/* View Transitions */
::view-transition-old(root),
::view-transition-new(root) {
    animation-duration: 0.3s;
}

/* PWA Install Button */
.install-card {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: none;
    /* Hidden by default */
}


/* Bottom Navigation - App Native Look */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    transform: none;
    background: rgba(18, 18, 23, 0.95);
    /* Más opaco para mejor contraste */
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
    border-radius: 0;
    display: flex;
    justify-content: space-around;
    padding: 0.8rem 1rem calc(0.8rem + var(--safe-bottom) + 5px);
    /* Extra padding bottom for safe area and visual balance */
    z-index: 1000;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    color: var(--text-dim);
    font-size: 0.7rem;
    font-weight: 500;
    cursor: pointer;
    background: transparent;
    /* Ensure explicit transparent */
    appearance: none;
    /* Reset native button style */
    -webkit-appearance: none;
    /* Reset native iOS button style */
    border: none;
    transition: all 0.3s cubic-bezier(0.23, 1, 0.32, 1);
    opacity: 0.7;
    flex: 1;
}

/* Compact Card for Mobile Lists */
.compact-card {
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 1rem;
    margin-bottom: 0.8rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.compact-card .icon {
    font-size: 1.5rem;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    flex-shrink: 0;
    /* Prevent icon from shrinking */
}

.nav-item svg,
.nav-icon {
    width: 26px;
    height: 26px;
    fill: currentColor;
    transition: transform 0.2s, color 0.2s;
    font-size: 1.5rem;
    /* Iconos más visibles */
    margin-bottom: 0;
}

.nav-item.active {
    color: white;
    opacity: 1;
}

.nav-item.active .nav-icon {
    transform: translateY(-2px);
    /* color: var(--primary);  Removed color tint for cleaner look, usually active = white/bright implies selection */
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

/* Floating Info Button Style */
.room-card-wrapper {
    position: relative;
    margin-bottom: 1rem;
}

.floating-info-btn {
    position: absolute;
    top: -10px;
    right: -5px;
    width: 36px;
    height: 36px;
    background: var(--primary-gradient);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(255, 77, 109, 0.4);
    z-index: 20;
    border: 2px solid var(--bg);
    /* Borde para separarlo visualmente de la tarjeta */
    cursor: pointer;
    font-size: 1rem;
    color: white;
    transition: transform 0.2s;
}

.floating-info-btn:active {
    transform: scale(0.9);
}


/* Toast Notification (Restored) */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--primary-gradient);
    color: white;
    padding: 1rem 2rem;
    border-radius: 50px;
    z-index: 5000;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    font-weight: 700;
    pointer-events: none;
    white-space: nowrap;
}

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

/* Mobile Adjustments */
@media (max-width: 480px) {
    h1 {
        font-size: 1.8rem;
    }

    .premium-card {
        padding: 1.8rem 1.2rem;
        border-radius: 24px;
    }

    .hero-emoji-main {
        font-size: 3rem;
    }
}

@keyframes modalPop {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* --- Global Toasts --- */
#toast-container {
    position: fixed;
    top: calc(1rem + var(--safe-top));
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    width: 95%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    background: rgba(25, 25, 30, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 12px 16px;
    color: white;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 12px;
    pointer-events: auto;
    animation: toastSlideIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    cursor: pointer;
    transition: transform 0.2s, opacity 0.2s;
}

.toast:active {
    transform: scale(0.98);
}

.toast-icon {
    width: 40px;
    height: 40px;
    background: var(--primary-gradient);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.2rem;
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 700;
    font-size: 0.9rem;
    margin-bottom: 2px;
}

.toast-body {
    font-size: 0.8rem;
    color: var(--text-dim);
}

@keyframes toastSlideIn {
    from {
        transform: translate(-50%, -30px);
        opacity: 0;
    }

    to {
        transform: translate(-50%, 0);
        opacity: 1;
    }
}

.toast-fade-out {
    opacity: 0;
    transform: scale(0.9);
}