@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

:root {
    --primary: hsl(215, 90%, 45%);
    --primary-dark: hsl(215, 90%, 35%);
    --secondary: hsl(190, 90%, 50%);
    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --bg-sidebar: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --border-color: #334155;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
}

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

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
}

.gradient-bg {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
}

.glass {
    background: rgba(30, 41, 59, 0.8);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-logo {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    object-fit: cover;
}

.sidebar-brand h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: white;
}

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

.sidebar-nav {
    flex: 1;
    padding: 1.5rem 1rem;
    overflow-y: auto;
}

.nav-section-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-secondary);
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.5rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s;
    margin-bottom: 0.25rem;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.nav-link.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.nav-link i {
    width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.2);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: white;
}

.user-details h4 {
    font-size: 0.875rem;
    font-weight: 600;
    color: white;
}

.user-details p {
    font-size: 0.75rem;
    color: var(--primary);
}

.btn-logout {
    width: 100%;
    padding: 0.625rem 1rem;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-secondary);
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.btn-logout:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 2rem;
    background: #0f172a;
    min-height: 100vh;
}

.page-header {
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 1.875rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.page-header p {
    color: var(--text-secondary);
}

/* Cards */
.card {
    background: var(--bg-card);
    border-radius: 1rem;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

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

.card-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.card-body {
    padding: 1.5rem;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-card);
    border-radius: 1rem;
    border: 1px solid var(--border-color);
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.stat-info h3 {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.stat-info .value {
    font-size: 1.75rem;
    font-weight: 700;
}

.stat-info .change {
    font-size: 0.75rem;
    margin-top: 0.25rem;
}

.stat-info .change.positive {
    color: var(--success);
}

.stat-info .change.negative {
    color: var(--danger);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.stat-icon.blue {
    background: rgba(59, 130, 246, 0.2);
    color: #3b82f6;
}

.stat-icon.green {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
}

.stat-icon.yellow {
    background: rgba(245, 158, 11, 0.2);
    color: #f59e0b;
}

.stat-icon.purple {
    background: rgba(168, 85, 247, 0.2);
    color: #a855f7;
}

/* Buttons */
.btn {
    padding: 0.625rem 1.25rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

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

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

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
    background: var(--bg-dark);
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: all 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.form-control::placeholder {
    color: var(--text-secondary);
}

/* Tables */
.table-container {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.table th {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    font-weight: 600;
}

.table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

/* Badge */
.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
}

.badge-warning {
    background: rgba(245, 158, 11, 0.2);
    color: #f59e0b;
}

.badge-danger {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.badge-primary {
    background: rgba(59, 130, 246, 0.2);
    color: #3b82f6;
}

/* Plan Cards */
.plans-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.plan-card {
    background: var(--bg-card);
    border-radius: 1rem;
    border: 1px solid var(--border-color);
    padding: 1.5rem;
    transition: all 0.3s;
    position: relative;
}

.plan-card:hover {
    transform: translateY(-4px);
    border-color: var(--primary);
}

.plan-card.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary);
}

.plan-card .plan-badge {
    position: absolute;
    top: -10px;
    right: 1rem;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
}

.plan-card.silver .plan-badge {
    background: linear-gradient(135deg, #9ca3af, #d1d5db);
    color: #1f2937;
}

.plan-card.gold .plan-badge {
    background: linear-gradient(135deg, #f59e0b, #fbbf24);
    color: #1f2937;
}

.plan-card.platinum .plan-badge {
    background: linear-gradient(135deg, #6366f1, #a855f7);
    color: white;
}

.plan-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.plan-name {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.plan-price {
    font-size: 2rem;
    font-weight: 800;
}

.plan-price span {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.plan-features {
    list-style: none;
    margin-bottom: 1.5rem;
}

.plan-features li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.plan-features li i {
    color: var(--success);
}

/* Auth Pages */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg-dark) 0%, #1e293b 100%);
    padding: 2rem;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    border-radius: 1.5rem;
    border: 1px solid var(--border-color);
    padding: 2.5rem;
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-logo {
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    border-radius: 16px;
}

.auth-header h1 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.auth-header p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.auth-footer {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.auth-footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

/* Wallet */
.wallet-balance {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    border-radius: 1rem;
    padding: 2rem;
    margin-bottom: 2rem;
    text-align: center;
}

.wallet-balance h2 {
    font-size: 0.875rem;
    font-weight: 500;
    opacity: 0.9;
    margin-bottom: 0.5rem;
}

.wallet-balance .amount {
    font-size: 3rem;
    font-weight: 800;
}

.crypto-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.crypto-card {
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: 1rem;
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.crypto-card:hover,
.crypto-card.selected {
    border-color: var(--primary);
}

.crypto-card i {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.crypto-card.btc i {
    color: #f7931a;
}

.crypto-card.ltc i {
    color: #345d9d;
}

/* Alerts */
.alert {
    padding: 1rem 1.25rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.alert-success {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: #22c55e;
}

.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #ef4444;
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: #f59e0b;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .mobile-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 1rem;
        background: var(--bg-card);
        border-bottom: 1px solid var(--border-color);
        position: sticky;
        top: 0;
        z-index: 50;
    }

    .menu-toggle {
        background: none;
        border: none;
        color: white;
        font-size: 1.5rem;
        cursor: pointer;
    }
}

@media (min-width: 769px) {
    .mobile-header {
        display: none;
    }
}

/* Loading Spinner */
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

/* =========================
   Responsive hardening
   ========================= */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  max-width: 100%;
  overflow-x: hidden;
}

/* Evita que strings largos (SIP, callerid, uniqueid, etc.) rompan el layout */
.table td, .table th,
.card, .card-body,
.content-header, .main-content,
.sidebar-brand, .sidebar-header {
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* Multimedia */
img, video, svg, canvas {
  max-width: 100%;
  height: auto;
}

/* IMPORTANTE: si usas flex, esto evita overflow horizontal */
.main-content { min-width: 0; }

/* Tablas: siempre dentro del contenedor, con scroll si hace falta */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.table {
  width: 100%;
  border-collapse: collapse;
}

/* Por defecto permite scroll en tablas grandes sin romper la pantalla */
.table th, .table td { white-space: nowrap; }
/* Si alguna columna quieres que rompa línea, ponle class="wrap" */
.table th.wrap, .table td.wrap { white-space: normal; }

/* Formularios */
input, select, textarea, button { max-width: 100%; }
.form-control { width: 100%; }

/* Bloques tipo code/logs */
pre, code {
  max-width: 100%;
  overflow-x: auto;
}

/* Ajustes móviles generales */
@media (max-width: 768px) {
  .app-container { display: block; }

  .main-content {
    width: 100% !important;
    margin-left: 0 !important;
  }

  /* márgenes más seguros */
  .content-header, .card { margin: 12px; }

  /* botones apilados */
  .btn { width: 100%; }
  .btn + .btn { margin-top: 8px; }

  /* tipografías y paddings de tabla */
  .table th, .table td { font-size: 0.9rem; padding: 10px 12px; }
}

@media (max-width: 420px) {
  .table th, .table td { font-size: 0.85rem; }
  .card-header h3 { font-size: 1rem; }
}


/* ===== Responsive fix (hard) ===== */
html, body { width:100%; max-width:100%; overflow-x:hidden; }
*, *::before, *::after { box-sizing:border-box; }

/* evita overflow por flex/grid */
.app-container, .main-content, .content, .content-wrapper { max-width:100%; overflow-x:hidden; }
.main-content { min-width:0; }

/* strings largos (SIP, callerid, uniqueid) */
.table td, .table th, .card, .card-body, .sidebar, .topbar, .navbar {
  overflow-wrap:anywhere;
  word-break:break-word;
}

/* tablas: scroll controlado */
.table-responsive { width:100%; overflow-x:auto; -webkit-overflow-scrolling:touch; }
.table { width:100%; }

/* topbar/fixed elements: evita que 100vw + padding rompa */
.topbar, .navbar, .header {
  left:0; right:0;
  width:auto;
  max-width:100%;
}

/* Dashboard buttons / actions: que envuelvan */
.dashboard-actions, .actions, .btn-row, .button-row {
  display:flex;
  flex-wrap:wrap;
  gap:12px;
  min-width:0;
}
.dashboard-actions > *, .actions > *, .btn-row > *, .button-row > * { flex: 1 1 160px; }

@media (max-width: 768px){
  /* apila acciones */
  .dashboard-actions, .actions, .btn-row, .button-row { flex-direction:column; }
  .dashboard-actions > *, .actions > *, .btn-row > *, .button-row > * { width:100%; }

  /* grids a 1 columna si tienes tarjetas */
  .grid, .stats-grid, .cards-grid { grid-template-columns: 1fr !important; }

  /* padding seguro */
  .main-content, .content, .content-wrapper { padding-left:12px; padding-right:12px; }
}

/* ================================ */
