:root {
    --bg-main: #0b0f19;
    --bg-sidebar: #111827;
    --bg-card: rgba(17, 24, 39, 0.7);
    --border-card: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(99, 102, 241, 0.3);
    
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    
    --color-indigo: #6366f1;
    --color-indigo-dark: #4f46e5;
    --color-indigo-light: rgba(99, 102, 241, 0.15);
    
    --color-emerald: #10b981;
    --color-emerald-light: rgba(16, 185, 129, 0.15);
    
    --color-rose: #f43f5e;
    --color-rose-light: rgba(244, 63, 94, 0.15);
    
    --font-sans: 'Inter', sans-serif;
    --font-heading: 'Outfit', sans-serif;
    --radius-lg: 16px;
    --radius-md: 10px;
    --radius-sm: 6px;
    
    --shadow-premium: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
    --transition-fast: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================
   RESET Y BASE
   ========================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-sans);
    line-height: 1.5;
    overflow-x: hidden;
    min-height: 100vh;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 700;
}

a {
    color: inherit;
    text-decoration: none;
}

button, input, select, textarea {
    font-family: inherit;
}

.hidden {
    display: none !important;
}

.text-indigo { color: var(--color-indigo); }
.text-emerald { color: var(--color-emerald); }
.text-rose { color: var(--color-rose); }
.font-semibold { font-weight: 600; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.p-0 { padding: 0 !important; }
.py-6 { padding-top: 1.5rem; padding-bottom: 1.5rem; }
.text-center { text-align: center; }
.uppercase { text-transform: uppercase; }
.tracking-wider { letter-spacing: 0.05em; }
.tracking-widest { letter-spacing: 0.1em; }

/* Flex & Grid Helpers */
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-end { display: flex; align-items: center; justify-content: flex-end; }
.flex-wrap { display: flex; flex-wrap: wrap; }
.flex-col { display: flex; flex-direction: column; }
.flex-col-center { display: flex; flex-direction: column; align-items: center; justify-content: center; }
.gap-1-5 { gap: 0.375rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-6 { gap: 1.5rem; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-span-2 { grid-column: span 2 / span 2; }

/* Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ==========================================
   BOTONES
   ========================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-indigo) 0%, var(--color-indigo-dark) 100%);
    color: white;
    box-shadow: 0 4px 15px -3px rgba(99, 102, 241, 0.4);
}
.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px -3px rgba(99, 102, 241, 0.5);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.05);
}
.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.12);
}

.btn-success {
    background: linear-gradient(135deg, var(--color-emerald) 0%, #059669 100%);
    color: white;
    box-shadow: 0 4px 15px -3px rgba(16, 185, 129, 0.4);
}
.btn-success:hover {
    transform: translateY(-1px);
}

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

.btn-block {
    width: 100%;
}

.btn-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}

/* ==========================================
   VISTA DE LOGIN (AUTH)
   ========================================== */
.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1.5rem;
    background: radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.15) 0%, transparent 45%),
                radial-gradient(circle at 90% 80%, rgba(16, 185, 129, 0.1) 0%, transparent 45%);
}

.auth-card {
    width: 100%;
    max-width: 440px;
    padding: 2.5rem;
    background: rgba(17, 24, 39, 0.8);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-premium);
    text-align: center;
}

.logo-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.auth-header h1 {
    font-size: 2.25rem;
    margin-bottom: 0.5rem;
    letter-spacing: -0.025em;
    background: linear-gradient(135deg, #fff 30%, var(--text-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.auth-header p {
    color: var(--text-secondary);
    font-size: 0.925rem;
    margin-bottom: 2rem;
}

.divider {
    display: flex;
    align-items: center;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 700;
    margin: 1.5rem 0;
}
.divider::before, .divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.divider::before { margin-right: .75em; }
.divider::after { margin-left: .75em; }

.dev-token-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.dev-token-form input {
    width: 100%;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-md);
    color: white;
    font-size: 0.875rem;
    text-align: center;
    transition: var(--transition-fast);
}
.dev-token-form input:focus {
    outline: none;
    border-color: var(--color-indigo);
    background: rgba(255, 255, 255, 0.07);
}

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

/* ==========================================
   SPA APP LAYOUT
   ========================================== */
.app-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-card);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-card);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.sidebar-logo h2 {
    font-size: 1.25rem;
    font-weight: 800;
    color: white;
}
.logo-emoji {
    font-size: 1.5rem;
}

.sidebar-nav {
    padding: 1.5rem 0.75rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    transition: var(--transition-fast);
}
.nav-item i {
    width: 18px;
    height: 18px;
}
.nav-item:hover {
    color: white;
    background: rgba(255, 255, 255, 0.04);
}
.nav-item.active {
    color: white;
    background: var(--color-indigo-light);
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.sidebar-footer {
    padding: 1.25rem 1rem;
    border-top: 1px solid var(--border-card);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    overflow: hidden;
}
.user-badge img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    background: #1f2937;
    border: 1.5px solid var(--color-indigo);
}
.user-info {
    overflow: hidden;
}
.user-info h4 {
    font-size: 0.85rem;
    font-weight: 600;
    color: white;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}
.user-info span {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.btn-logout {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
}
.btn-logout:hover {
    color: var(--color-rose);
    background: var(--color-rose-light);
}

/* Main Area */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.main-header {
    height: 70px;
    padding: 0 2rem;
    border-bottom: 1px solid var(--border-card);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(11, 15, 25, 0.45);
    backdrop-filter: blur(8px);
}

.header-title h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: white;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.credits-display {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--color-indigo-light);
    border: 1px solid rgba(99, 102, 241, 0.2);
    padding: 0.5rem 0.875rem;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
}
.credits-display strong {
    font-size: 0.95rem;
    color: white;
}

/* ==========================================
   TARJETAS Y ELEMENTOS GLOBLALES
   ========================================== */
.tab-content {
    display: none;
    padding: 2rem;
    overflow-y: auto;
    flex: 1;
}
.tab-content.active {
    display: block;
}

.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: var(--transition-fast);
}
.card:hover {
    border-color: rgba(255, 255, 255, 0.1);
}

.glass-card {
    background: rgba(17, 24, 39, 0.45);
    backdrop-filter: blur(16px);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.2);
}

.card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-card);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card-header h2 {
    font-size: 1rem;
    font-weight: 600;
    color: white;
}

.card-body {
    padding: 1.5rem;
}

/* Badge System */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: 50px;
    line-height: 1;
}
.badge-success {
    background: var(--color-emerald-light);
    color: var(--color-emerald);
    border: 1px solid rgba(16, 185, 129, 0.2);
}
.badge-info {
    background: var(--color-indigo-light);
    color: var(--color-indigo);
    border: 1px solid rgba(99, 102, 241, 0.2);
}
.badge-danger {
    background: var(--color-rose-light);
    color: var(--color-rose);
    border: 1px solid rgba(244, 63, 94, 0.2);
}

.dot {
    width: 6px;
    height: 6px;
    background-color: currentColor;
    border-radius: 50%;
}

/* ==========================================
   PÁGINAS ESPECÍFICAS
   ========================================== */

/* Account Card Info */
.account-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2.25rem 1rem;
}
.big-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 1rem;
    border: 2px solid var(--color-indigo);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

/* Subscription Plan view */
.plan-badge {
    background: linear-gradient(135deg, var(--color-indigo) 0%, #a855f7 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-size: 2rem;
}

/* Credits Progress Bar */
.credits-count {
    font-size: 3rem;
    font-family: var(--font-heading);
    font-weight: 800;
    line-height: 1;
    background: linear-gradient(135deg, white 60%, var(--color-indigo) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.progress-bar-container {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 50px;
    overflow: hidden;
}
.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--color-indigo) 0%, var(--color-emerald) 100%);
    border-radius: 50px;
    transition: width 0.5s ease;
}

/* Forms */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.form-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}
.help-text {
    font-size: 0.75rem;
    color: var(--text-muted);
}
input[type="text"], select, textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-md);
    color: white;
    font-size: 0.875rem;
    transition: var(--transition-fast);
}
input[type="text"]:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--color-indigo);
    background: rgba(255, 255, 255, 0.06);
}
textarea {
    resize: vertical;
}

/* Tips list */
.tips-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.tips-list li {
    position: relative;
    padding-left: 1.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}
.tips-list li::before {
    content: '\2726';
    position: absolute;
    left: 0;
    color: var(--color-indigo);
    font-weight: bold;
}

/* Tables */
.table-responsive {
    overflow-x: auto;
}
.table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.875rem;
}
.table th, .table td {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-card);
}
.table th {
    background: rgba(255, 255, 255, 0.02);
    font-weight: 600;
    color: white;
}
.table tr:hover td {
    background: rgba(255, 255, 255, 0.01);
}

/* ==========================================
   INBOX & TICKETS LAYOUT
   ========================================== */
.inbox-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 1.5rem;
    height: 100%;
}

.tickets-panel {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100%;
}
.tickets-list {
    overflow-y: auto;
    flex: 1;
}

.ticket-item {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-card);
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.ticket-item:hover {
    background: rgba(255, 255, 255, 0.03);
}
.ticket-item.active {
    background: var(--color-indigo-light);
    border-left: 3px solid var(--color-indigo);
}

.ticket-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: var(--color-indigo);
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.ticket-details {
    overflow: hidden;
    flex: 1;
}
.ticket-client-id {
    font-size: 0.85rem;
    font-weight: 600;
    color: white;
}
.ticket-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 0.25rem;
}

.chat-panel {
    height: 100%;
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: rgba(11, 15, 25, 0.2);
}

.chat-empty {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}
.big-icon {
    width: 48px;
    height: 48px;
}

.message-bubble {
    max-width: 70%;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-lg);
    font-size: 0.875rem;
    word-break: break-word;
}
.message-bubble.user {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border-bottom-left-radius: 0;
}
.message-bubble.assistant {
    align-self: flex-end;
    background: var(--color-indigo);
    color: white;
    border-bottom-right-radius: 0;
}

/* Custom CSS Tooltip/Grid fixes for superadmin */
.admin-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.admin-actions input {
    width: 70px;
    padding: 0.375rem 0.5rem;
    text-align: center;
}
.admin-actions select {
    width: 110px;
    padding: 0.375rem 0.5rem;
}
