/* AutoResponder - style.css */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0d0f14;
  --bg2: #13161e;
  --bg3: #1a1e2a;
  --bg4: #222736;
  --border: #2a2f3d;
  --border2: #363c50;
  --text: #e8eaf0;
  --text2: #8b91a8;
  --text3: #555d75;
  --accent: #00e5a0;
  --accent-dim: #00b87d;
  --accent-bg: rgba(0,229,160,0.08);
  --accent-bg2: rgba(0,229,160,0.15);
  --danger: #ff4d6d;
  --danger-bg: rgba(255,77,109,0.1);
  --warn: #ffb830;
  --warn-bg: rgba(255,184,48,0.1);
  --info: #4d9fff;
  --info-bg: rgba(77,159,255,0.1);
  --wa: #25d366;
  --tg: #229ed9;
  --ig: #e1306c;
  --fb: #1877f2;
  --radius: 10px;
  --radius-lg: 14px;
  --sidebar-w: 230px;
  --font: 'Inter', sans-serif;
  --font-display: 'Space Grotesk', sans-serif;
  --transition: 0.18s ease;
}

body { font-family: var(--font); background: var(--bg); color: var(--text); min-height: 100vh; }

/* ===== AUTH ===== */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 1rem; }
.auth-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 2.5rem 2rem; width: 100%; max-width: 400px; }
.auth-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 2rem; }
.auth-logo .logo-icon { width: 36px; height: 36px; background: var(--accent); border-radius: 8px; display: flex; align-items: center; justify-content: center; color: #0d0f14; font-size: 18px; }
.auth-logo .logo-text { font-family: var(--font-display); font-size: 1.3rem; font-weight: 700; color: var(--text); }
.auth-card h2 { font-family: var(--font-display); font-size: 1.5rem; font-weight: 600; margin-bottom: 0.25rem; }
.auth-card p { color: var(--text2); font-size: 0.9rem; margin-bottom: 1.75rem; }
.auth-card .error-msg { background: var(--danger-bg); border: 1px solid var(--danger); color: var(--danger); border-radius: var(--radius); padding: 0.75rem 1rem; font-size: 0.875rem; margin-bottom: 1rem; }

/* ===== FORM ELEMENTS ===== */
.field { margin-bottom: 1rem; }
.field label { display: block; font-size: 0.8rem; font-weight: 500; color: var(--text2); margin-bottom: 0.4rem; text-transform: uppercase; letter-spacing: 0.05em; }
.field input, .field select, .field textarea {
  width: 100%; background: var(--bg3); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius); padding: 0.65rem 0.875rem; font-family: var(--font); font-size: 0.9rem;
  transition: border-color var(--transition), box-shadow var(--transition); outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0,229,160,0.12); }
.field textarea { resize: vertical; min-height: 90px; }
.field select option { background: var(--bg3); }

/* ===== BUTTONS ===== */
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 0.6rem 1.2rem; border-radius: var(--radius); font-family: var(--font); font-size: 0.875rem; font-weight: 500; cursor: pointer; border: none; transition: all var(--transition); text-decoration: none; }
.btn-primary { background: var(--accent); color: #0d0f14; }
.btn-primary:hover { background: var(--accent-dim); }
.btn-outline { background: transparent; border: 1px solid var(--border2); color: var(--text2); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-bg); }
.btn-danger { background: transparent; border: 1px solid var(--border2); color: var(--danger); }
.btn-danger:hover { background: var(--danger-bg); border-color: var(--danger); }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.8rem; }
.btn-full { width: 100%; justify-content: center; padding: 0.75rem; }
.btn-icon { padding: 0.4rem; width: 32px; height: 32px; justify-content: center; }

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

/* ===== SIDEBAR ===== */
.sidebar { width: var(--sidebar-w); background: var(--bg2); border-right: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; height: 100vh; overflow-y: auto; transition: transform var(--transition); }
.sidebar-logo { display: flex; align-items: center; gap: 10px; padding: 1.25rem 1.2rem; border-bottom: 1px solid var(--border); }
.logo-icon { width: 32px; height: 32px; background: var(--accent); border-radius: 7px; display: flex; align-items: center; justify-content: center; color: #0d0f14; font-size: 16px; flex-shrink: 0; }
.logo-text { font-family: var(--font-display); font-weight: 700; font-size: 1rem; color: var(--text); }
.sidebar-nav { flex: 1; padding: 0.75rem 0.6rem; display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 0.6rem 0.8rem; border-radius: var(--radius); color: var(--text2); text-decoration: none; font-size: 0.875rem; font-weight: 500; transition: all var(--transition); cursor: pointer; }
.nav-item i { width: 18px; text-align: center; font-size: 15px; flex-shrink: 0; }
.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active { background: var(--accent-bg2); color: var(--accent); }
.sidebar-footer { padding: 0.75rem 0.6rem; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; }
.nav-logout:hover { color: var(--danger); background: var(--danger-bg); }

/* ===== MAIN ===== */
.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar { display: flex; align-items: center; gap: 1rem; padding: 0 1.5rem; height: 60px; border-bottom: 1px solid var(--border); background: var(--bg2); flex-shrink: 0; }
.menu-toggle { display: none; background: none; border: none; color: var(--text2); font-size: 1.1rem; cursor: pointer; padding: 0.4rem; }
.page-title { font-family: var(--font-display); font-size: 1.1rem; font-weight: 600; flex: 1; }
.plan-badge { background: var(--accent-bg); color: var(--accent); border: 1px solid rgba(0,229,160,0.3); border-radius: 20px; padding: 0.2rem 0.75rem; font-size: 0.75rem; font-weight: 600; }
.page-body { flex: 1; overflow-y: auto; padding: 1.5rem; }

/* ===== CARDS ===== */
.card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.25rem; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; }
.card-title { font-family: var(--font-display); font-size: 0.95rem; font-weight: 600; }

/* ===== STATS GRID ===== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.25rem; }
.stat-label { font-size: 0.75rem; font-weight: 500; color: var(--text2); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 0.5rem; }
.stat-value { font-family: var(--font-display); font-size: 2rem; font-weight: 700; line-height: 1; }
.stat-value.green { color: var(--accent); }
.stat-value.blue { color: var(--info); }
.stat-value.orange { color: var(--warn); }
.stat-sub { font-size: 0.75rem; color: var(--text3); margin-top: 0.35rem; }

/* ===== TABLE ===== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
th { text-align: left; padding: 0.6rem 0.875rem; color: var(--text2); font-size: 0.75rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 0.75rem 0.875rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg3); }

/* ===== BADGES ===== */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 0.2rem 0.6rem; border-radius: 20px; font-size: 0.75rem; font-weight: 500; }
.badge-green { background: rgba(0,229,160,0.12); color: var(--accent); }
.badge-red { background: var(--danger-bg); color: var(--danger); }
.badge-gray { background: var(--bg4); color: var(--text2); }
.badge-wa { background: rgba(37,211,102,0.12); color: var(--wa); }
.badge-tg { background: rgba(34,158,217,0.12); color: var(--tg); }
.badge-ig { background: rgba(225,48,108,0.12); color: var(--ig); }
.badge-fb { background: rgba(24,119,242,0.12); color: var(--fb); }

/* ===== APP TOGGLE CARDS ===== */
.apps-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.app-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.5rem; display: flex; flex-direction: column; align-items: center; gap: 0.75rem; text-align: center; transition: border-color var(--transition); }
.app-card.enabled { border-color: var(--accent); }
.app-icon { width: 52px; height: 52px; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; }
.app-name { font-family: var(--font-display); font-weight: 600; font-size: 0.95rem; }

/* ===== TOGGLE SWITCH ===== */
.toggle-wrap { display: flex; align-items: center; gap: 0.75rem; }
.toggle { position: relative; width: 44px; height: 24px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; inset: 0; background: var(--bg4); border-radius: 24px; cursor: pointer; transition: background var(--transition); }
.toggle-slider::before { content: ''; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: var(--text2); border-radius: 50%; transition: transform var(--transition), background var(--transition); }
.toggle input:checked + .toggle-slider { background: var(--accent-bg2); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); background: var(--accent); }

/* ===== MODAL ===== */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.7); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 1rem; opacity: 0; pointer-events: none; transition: opacity var(--transition); }
.modal-overlay.show { opacity: 1; pointer-events: all; }
.modal { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-lg); width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border); }
.modal-title { font-family: var(--font-display); font-weight: 600; }
.modal-body { padding: 1.5rem; }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border); display: flex; gap: 0.75rem; justify-content: flex-end; }

/* ===== EMPTY STATE ===== */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text3); }
.empty-state i { font-size: 2.5rem; margin-bottom: 1rem; display: block; }
.empty-state p { font-size: 0.9rem; margin-bottom: 1.25rem; }

/* ===== LIVE PING ===== */
.ping-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); display: inline-block; position: relative; }
.ping-dot::after { content: ''; position: absolute; inset: -4px; border-radius: 50%; background: var(--accent); opacity: 0.4; animation: ping 1.5s ease-out infinite; }
@keyframes ping { 0% { transform: scale(1); opacity: 0.4; } 100% { transform: scale(2.5); opacity: 0; } }

/* ===== HORARIOS TABLE ===== */
.schedule-table { width: 100%; border-collapse: collapse; }
.schedule-table td { padding: 0.6rem 0.5rem; }
.schedule-table .day-label { font-weight: 500; font-size: 0.875rem; width: 100px; }
.schedule-table input[type=time] { background: var(--bg3); border: 1px solid var(--border); color: var(--text); border-radius: 7px; padding: 0.4rem 0.6rem; font-size: 0.85rem; font-family: var(--font); width: 110px; }

/* ===== CHECKBOX APPS ===== */
.apps-check-group { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.app-check-btn { padding: 0.35rem 0.75rem; border-radius: 20px; border: 1px solid var(--border); background: var(--bg3); color: var(--text2); font-size: 0.8rem; font-weight: 500; cursor: pointer; transition: all var(--transition); display: flex; align-items: center; gap: 5px; }
.app-check-btn.selected-wa { border-color: var(--wa); background: rgba(37,211,102,0.1); color: var(--wa); }
.app-check-btn.selected-tg { border-color: var(--tg); background: rgba(34,158,217,0.1); color: var(--tg); }
.app-check-btn.selected-ig { border-color: var(--ig); background: rgba(225,48,108,0.1); color: var(--ig); }
.app-check-btn.selected-fb { border-color: var(--fb); background: rgba(24,119,242,0.1); color: var(--fb); }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 500; transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: 4px 0 24px rgba(0,0,0,0.5); }
  .menu-toggle { display: flex; align-items: center; justify-content: center; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ===== SIDEBAR OVERLAY (móvil) ===== */
#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 499;
  backdrop-filter: blur(2px);
}
#sidebar-overlay.show { display: block; }

.sidebar-close {
  display: none;
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text2);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.25rem;
}

/* ===== RESPONSIVE MÓVIL ===== */
@media (max-width: 768px) {

  /* Sidebar deslizable */
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    z-index: 500;
    transform: translateX(-100%);
    width: min(var(--sidebar-w), 85vw);
    transition: transform 0.25s ease;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 32px rgba(0,0,0,0.6);
  }
  .sidebar-close { display: flex; align-items: center; justify-content: center; }
  .menu-toggle { display: flex; align-items: center; justify-content: center; }

  /* Layout principal */
  .app-page { height: auto; min-height: 100vh; overflow: auto; }
  .main-content { overflow: visible; height: auto; }
  .page-body {
    padding: 1rem 0.875rem;
    overflow: visible;
    height: auto;
  }

  /* Topbar */
  .topbar { padding: 0 0.875rem; height: 54px; }
  .page-title { font-size: 1rem; }

  /* Stats */
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
  .stat-value { font-size: 1.6rem; }

  /* Cards */
  .card { padding: 1rem; border-radius: var(--radius); }

  /* Tablas — scroll horizontal */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 500px; }

  /* Botones más grandes para touch */
  .btn { min-height: 40px; }
  .btn-sm { min-height: 34px; }
  .btn-icon { width: 36px; height: 36px; }

  /* Inputs táctiles */
  .field input, .field select, .field textarea {
    font-size: 16px; /* Evita zoom automático en iOS */
    padding: 0.75rem 0.875rem;
    min-height: 44px;
  }

  /* Apps grid */
  .apps-grid { grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }

  /* Modal full-screen en móvil */
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal {
    max-width: 100%;
    width: 100%;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    max-height: 92vh;
  }

  /* Auth card */
  .auth-card { padding: 1.75rem 1.25rem; }

  /* Ocultar texto largo en topbar */
  .topbar-right .plan-badge { font-size: 0.7rem; padding: 0.15rem 0.6rem; }
}

/* ===== RESPONSIVE TABLET ===== */
@media (max-width: 1024px) and (min-width: 769px) {
  :root { --sidebar-w: 200px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .page-body { padding: 1.25rem; }
}

/* ===== PANTALLAS MUY PEQUEÑAS (< 360px) ===== */
@media (max-width: 360px) {
  .stats-grid { grid-template-columns: 1fr; }
  .apps-grid { grid-template-columns: 1fr; }
  .page-body { padding: 0.75rem; }
  .topbar { padding: 0 0.75rem; }
}

/* ===== TOUCH — eliminar highlight azul en iOS/Android ===== */
* { -webkit-tap-highlight-color: transparent; }
a, button { touch-action: manipulation; }

/* ===== SCROLL SUAVE EN MÓVIL ===== */
.page-body, .sidebar { -webkit-overflow-scrolling: touch; }
