@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg: #0F0F13;
  --card: rgba(25, 25, 30, 0.6);
  --primary: #FE2C55;
  --primary-hover: #E02447;
  --cyan: #25F4EE;
  --cyan-hover: #1DD2CD;
  --success: #10b981;
  --error: #ef4444;
  --txt: #FFFFFF;
  --txt-mut: #D1D5DB;
  --border: rgba(255, 255, 255, 0.12);
  --border-focus: rgba(37, 244, 238, 0.5);
  --glow-pink: rgba(254, 44, 85, 0.15);
  --glow-cyan: rgba(37, 244, 238, 0.15);
}

* { 
  box-sizing: border-box; 
  margin: 0; 
  padding: 0; 
}

body {
  background: var(--bg);
  background-image: 
    radial-gradient(circle at 0% 0%, var(--glow-pink) 0%, transparent 40%),
    radial-gradient(circle at 100% 100%, var(--glow-cyan) 0%, transparent 40%);
  background-attachment: fixed;
  color: var(--txt); 
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-tap-highlight-color: transparent;
  user-select: none; /* Native app feel */
}

body::-webkit-scrollbar {
  width: 8px;
}
body::-webkit-scrollbar-track {
  background: transparent;
}
body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 10px;
}

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.screen.hidden {
  display: none !important;
}

/* Login and Register Screens */
#login-screen, #register-screen {
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-box {
  width: 100%;
  max-width: 360px;
  background: var(--card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}
.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(254, 44, 85, 0.2), rgba(37, 244, 238, 0.2));
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  margin: 0 auto;
}
.logo svg {
  width: 28px;
  height: 28px;
}
.login-box h2 {
  font-size: 24px;
  font-weight: 700;
  background: linear-gradient(90deg, #FFFFFF, #E2E2E2);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.login-box p {
  font-size: 14px;
  color: var(--txt-mut);
}
.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
}
.field-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--txt-mut);
}
.input {
  background: rgba(0, 0, 0, 0.4); 
  border: 1px solid var(--border); 
  border-radius: 8px; 
  padding: 12px; 
  color: var(--txt); 
  font-size: 14px; 
  font-family: 'Inter', sans-serif;
  outline: none; 
  width: 100%;
  transition: all 0.2s ease;
}
.input:focus {
  border-color: var(--cyan); 
  background: rgba(0, 0, 0, 0.6);
  box-shadow: 0 0 0 3px rgba(37, 244, 238, 0.15);
}
.error-msg {
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  display: none;
}

/* Dashboard Header */
.hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 32px;
  border-bottom: 1px solid var(--border);
  background: rgba(15, 15, 19, 0.8);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.hdr-left {
  display: flex;
  align-items: center;
  gap: 16px;
}
.hdr-tt h1 {
  font-size: 20px;
  font-weight: 700;
}
.hdr-tt p {
  font-size: 13px;
  color: var(--cyan);
  font-weight: 500;
}

/* Content Layout */
.dashboard-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.dashboard-wrapper {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.sidebar {
  width: 280px;
  background: rgba(15, 15, 19, 0.4);
  border-right: 1px solid var(--border);
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.main-content {
  flex: 1;
  padding: 32px;
  overflow-y: auto;
}

.dashboard-grid-main {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

.dashboard-col {
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.device-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.device-card {
  background: rgba(0,0,0,0.3);
  padding: 16px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.05);
}

@media (max-width: 768px) {
  .dashboard-layout {
    height: auto;
    overflow: visible;
  }
  
  .dashboard-wrapper {
    flex-direction: column;
    overflow: visible;
  }
  
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 280px;
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    border-right: 1px solid var(--border);
    border-bottom: none;
    background: var(--bg);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  
  .main-content {
    padding: 16px;
    overflow: visible;
  }
  
  .dashboard-grid-main {
    grid-template-columns: 1fr;
  }

  .grid {
    grid-template-columns: 1fr;
  }
  
  .device-grid {
    display: flex;
    flex-direction: column;
  }
  
  .ios-card {
    order: 1; /* iPhone on top */
  }
  
  .android-card {
    order: 2; /* Android below */
  }

  .center-mobile {
    text-align: center !important;
    justify-content: center !important;
  }

  .center-mobile-flex {
    justify-content: center !important;
  }

  .center-mobile-list {
    list-style-position: inside !important;
    margin-left: 0 !important;
    padding-left: 0 !important;
    text-align: center !important;
  }
}

.card {
  background: var(--card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.card h3 {
  font-size: 16px;
  font-weight: 600;
}
.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.1);
}
.badge.ativo {
  background: rgba(16, 185, 129, 0.15);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.3);
}
.badge.expirado {
  background: rgba(254, 44, 85, 0.15);
  color: var(--primary);
  border: 1px solid rgba(254, 44, 85, 0.3);
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 14px;
}
.info-row:last-child {
  border-bottom: none;
}
.info-row span {
  color: var(--txt-mut);
}

.webhook-url-box {
  background: rgba(0, 0, 0, 0.4);
  border: 1px dashed rgba(37, 244, 238, 0.4);
  padding: 12px 16px;
  border-radius: 8px;
  color: var(--cyan);
  font-family: monospace;
  font-size: 13px;
  word-break: break-all;
}

.desc {
  font-size: 13px;
  color: var(--txt-mut);
  line-height: 1.5;
}

/* Buttons */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 10px;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: 'Inter', sans-serif;
}
.btn-sm {
  padding: 8px 16px;
  font-size: 12px;
}
.btn.primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 12px rgba(254, 44, 85, 0.25);
}
.btn.primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 6px 16px rgba(254, 44, 85, 0.35);
}
.btn.ghost {
  background: rgba(255, 255, 255, 0.05);
  color: var(--txt);
  border: 1px solid var(--border);
}
.btn.ghost:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

/* Sales List */
.sales-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 300px;
  overflow-y: auto;
}
.sales-list::-webkit-scrollbar {
  width: 4px;
}
.sales-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}
.sale-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  animation: slideIn 0.3s ease-out;
}
@keyframes slideIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}
.sale-item-info strong {
  display: block;
  font-size: 14px;
  color: var(--cyan);
}
.sale-item-info span {
  font-size: 12px;
  color: var(--txt-mut);
}
.sale-item-val {
  font-size: 16px;
  font-weight: 700;
  color: var(--success);
}

.pulse-indicator {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--success);
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* MODAL STYLES */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  opacity: 1;
  transition: opacity 0.2s ease;
}
.modal-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}
.modal-content {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 90%;
  max-width: 400px;
  padding: 24px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  transform: translateY(0);
  transition: transform 0.2s ease;
}
.modal-overlay.hidden .modal-content {
  transform: translateY(20px);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.modal-header h3 {
  font-size: 16px;
  margin: 0;
}
.btn-close-modal {
  background: transparent;
  border: none;
  color: var(--txt-mut);
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: color 0.2s;
}
.btn-close-modal:hover {
  color: var(--txt);
}
.btn.secondary.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

/* SPA Views & Elements */
.view { display: none; animation: fadeIn 0.3s ease; }
.view.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Sidebar Nav */
.sidebar-header { margin-bottom: 32px; display: flex; align-items: center; gap: 12px; }
.sidebar-brand h2 { font-size: 18px; font-weight: 700; color: #fff; }
.nav-section { font-size: 11px; font-weight: 700; color: var(--txt-mut); margin-bottom: 8px; letter-spacing: 0.5px; padding-left: 12px; }
.nav-link { display: flex; align-items: center; gap: 12px; padding: 12px; color: var(--txt-mut); text-decoration: none; border-radius: 8px; font-size: 14px; font-weight: 500; transition: all 0.2s; margin-bottom: 4px; }
.nav-link:hover { background: rgba(255,255,255,0.05); color: #fff; }
.nav-link.active { background: linear-gradient(90deg, rgba(37, 244, 238, 0.15), transparent); color: var(--cyan); border-left: 3px solid var(--cyan); }

/* New Top Nav Tabs */
.top-nav-link { margin-bottom: 0; padding: 8px 16px; border-radius: 8px; font-weight: 600; color: var(--txt-mut); background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.05); transition: all 0.2s; white-space: nowrap; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
.top-nav-link:hover { background: rgba(255,255,255,0.08); color: #fff; border-color: rgba(255,255,255,0.1); }
.top-nav-link.active { background: #1a56db; color: #fff; border-color: #1a56db; box-shadow: 0 4px 12px rgba(26, 86, 219, 0.4); }

.desktop-only { display: flex; }
.mobile-only { display: none; }

/* Topbar profile */
.hdr-right { position: relative; display: flex; align-items: center; }
.btn-profile { background: transparent; border: none; display: flex; align-items: center; gap: 12px; cursor: pointer; color: var(--txt); font-family: inherit; text-align: left; padding: 4px 8px; border-radius: 8px; transition: background 0.2s; }
.btn-profile:hover { background: rgba(255,255,255,0.05); }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--cyan)); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 16px; color: #fff; }
.profile-info { display: flex; flex-direction: column; }
.profile-info strong { font-size: 13px; font-weight: 600; color: #fff; }
.profile-info span { font-size: 11px; color: var(--txt-mut); }
.dropdown-icon { color: var(--txt-mut); }

/* Profile Dropdown */
.profile-dropdown { position: absolute; top: 100%; right: 0; margin-top: 12px; width: 280px; background: rgba(25, 25, 30, 0.95); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 32px rgba(0,0,0,0.5); z-index: 50; overflow: hidden; transform-origin: top right; transition: all 0.2s ease; }
.profile-dropdown.hidden { opacity: 0; pointer-events: none; transform: scale(0.95); }
.dropdown-header { padding: 16px; border-bottom: 1px solid rgba(255,255,255,0.05); display: flex; justify-content: space-between; align-items: center; }
.dropdown-body { padding: 16px; border-bottom: 1px solid rgba(255,255,255,0.05); }
.info-row-sm { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.info-row-sm span { color: var(--txt-mut); }
.dropdown-footer { padding: 16px; }

/* Dashboard Home */
.filter-bar { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-bottom: 24px; }
.filter-buttons { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.btn-filter { background: rgba(255,255,255,0.05); border: 1px solid var(--border); border-radius: 8px; color: var(--txt-mut); padding: 8px 16px; font-size: 13px; font-weight: 500; cursor: pointer; transition: all 0.2s; }
.btn-filter:hover { background: rgba(255,255,255,0.1); color: #fff; }
.btn-filter.active { background: rgba(37, 244, 238, 0.15); color: var(--cyan); border-color: rgba(37, 244, 238, 0.3); }
.input-select { background: rgba(0,0,0,0.4); border: 1px solid var(--border); border-radius: 8px; color: var(--txt); padding: 8px 12px; font-size: 13px; outline: none; cursor: pointer; }
.kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.kpi-card { background: linear-gradient(145deg, rgba(25,25,30,0.6) 0%, rgba(15,15,19,0.8) 100%); border: 1px solid var(--border); border-radius: 16px; padding: 24px; display: flex; align-items: center; gap: 20px; box-shadow: 0 4px 20px rgba(0,0,0,0.2); }
.kpi-icon { width: 56px; height: 56px; border-radius: 16px; display: flex; align-items: center; justify-content: center; }
.kpi-info { display: flex; flex-direction: column; gap: 4px; }
.kpi-label { font-size: 13px; color: var(--txt-mut); font-weight: 500; }
.kpi-value { font-size: 28px; font-weight: 700; color: #fff; }

@media (max-width: 768px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .desktop-only { display: none !important; }
  .mobile-only { display: flex !important; }
  .filter-bar { justify-content: center !important; }
  .filter-buttons { justify-content: center !important; }
}

@media (max-width: 768px) {
  .top-nav {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 0 16px;
    margin-bottom: 24px !important;
  }
  .top-nav-link {
    font-size: 13px !important;
    padding: 10px 8px !important;
    text-align: center;
    white-space: normal !important;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
  }
  #custom-date-picker {
    flex-direction: column;
    width: 100%;
    margin-left: 0 !important;
    margin-top: 12px;
  }
  #custom-date-picker > input, #custom-date-picker > button {
    width: 100%;
    box-sizing: border-box;
  }
  #mobile-plan-badge-container {
    display: flex !important;
  }
}


@keyframes tutBounceRight { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(8px); } }


/* Tutorial Grid */
.tut-grid { grid-template-columns: 1fr 1fr; }
.tut-chevron.rotated { transform: rotate(180deg); }
@media (max-width: 768px) { .tut-grid { grid-template-columns: 1fr; } }


/* Tutorial accordion */
.tut-hidden { display: none !important; }


/* Pulse Alert for Warning */
@keyframes borderPulse { 0% { box-shadow: 0 0 0 0 rgba(255, 152, 0, 0.4); } 70% { box-shadow: 0 0 0 10px rgba(255, 152, 0, 0); } 100% { box-shadow: 0 0 0 0 rgba(255, 152, 0, 0); } }
.pulse-alert { animation: borderPulse 2s infinite; }
