/* ================================================
   MyESS — Portal Stylesheet
   Extends the ESS brand (eastall.home.css)
   ================================================ */

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700;800&display=swap');

/* ================================================
   CSS VARIABLES (inherits from ESS, adds portal vars)
   ================================================ */

:root {
  --bg-color:       #121212;
  --surface:        #1a1a1a;
  --surface-2:      #222222;
  --surface-hover:  #2a2a2a;
  --text-color:     #e6e6e6;
  --muted-text:     rgba(230, 230, 230, 0.6);
  --dim-text:       rgba(230, 230, 230, 0.35);

  --main-color-1:   #FF0000;
  --main-color-2:   #0033CC;
  --accent-gold:    #FFD700;
  --discord-color:  #5865F2;
  --stripe-color:   #635BFF;
  --success:        #22c55e;
  --warning:        #f59e0b;
  --danger:         #ef4444;
  --info:           #3b82f6;

  --nav-bg:         rgba(18, 18, 18, 0.97);
  --sidebar-bg:     #161616;
  --sidebar-width:  260px;
  --border-color:   rgba(255, 255, 255, 0.07);
  --border:         1px solid var(--border-color);
  --header-height:  64px;

  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  16px;
  --radius-xl:  24px;

  --shadow-sm:  0 2px 8px rgba(0,0,0,0.3);
  --shadow-md:  0 8px 24px rgba(0,0,0,0.4);
  --shadow-red: 0 8px 24px rgba(255,0,0,0.15);
}

body.light-mode {
  --bg-color:      #f0f0f0;
  --surface:       #ffffff;
  --surface-2:     #f5f5f5;
  --surface-hover: #ebebeb;
  --text-color:    #111111;
  --muted-text:    rgba(0,0,0,0.55);
  --dim-text:      rgba(0,0,0,0.3);
  --nav-bg:        rgba(255,255,255,0.97);
  --sidebar-bg:    #ffffff;
  --border-color:  rgba(0,0,0,0.09);
  --border:        1px solid var(--border-color);
}

/* ================================================
   RESET & BASE
   ================================================ */

*, *::before, *::after {
  margin: 0; padding: 0;
  box-sizing: border-box;
  font-family: 'Poppins', sans-serif;
}

html, body { height: 100%; }

body {
  background-color: var(--bg-color);
  color: var(--text-color);
  transition: background 0.3s ease, color 0.3s ease;
  overflow-x: hidden;
}

a { text-decoration: none; color: inherit; }

/* ================================================
   PORTAL LAYOUT (sidebar + main)
   ================================================ */

.portal-layout {
  display: flex;
  min-height: 100vh;
}

/* ================================================
   SIDEBAR
   ================================================ */

.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 200;
  transition: transform 0.3s ease, background 0.3s ease;
  overflow-y: auto;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 24px;
  border-bottom: var(--border);
  min-height: var(--header-height);
}

.sidebar-logo img {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.sidebar-logo span {
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.sidebar-logo .logo-sub {
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--muted-text);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  display: block;
  line-height: 1;
  margin-top: 1px;
}

/* Nav groups */
.sidebar-nav {
  padding: 16px 12px;
  flex: 1;
}

.nav-group {
  margin-bottom: 28px;
}

.nav-group-label {
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim-text);
  padding: 0 12px;
  margin-bottom: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  color: var(--muted-text);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.nav-item:hover {
  background: var(--surface-hover);
  color: var(--text-color);
}

.nav-item.active {
  background: rgba(255, 0, 0, 0.12);
  color: var(--main-color-1);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 60%;
  background: var(--main-color-1);
  border-radius: 0 3px 3px 0;
}

.nav-item .material-symbols-outlined {
  font-size: 20px;
  flex-shrink: 0;
}

.nav-badge {
  margin-left: auto;
  background: var(--main-color-1);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 20px;
  min-width: 20px;
  text-align: center;
}

/* Sidebar user section */
.sidebar-user {
  padding: 16px;
  border-top: var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,0,0,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--main-color-1);
  flex-shrink: 0;
  overflow: hidden;
}

.user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-info { flex: 1; overflow: hidden; }
.user-name {
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role {
  font-size: 0.68rem;
  color: var(--muted-text);
  text-transform: capitalize;
}

.sidebar-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  color: var(--muted-text);
  transition: all 0.2s ease;
  flex-shrink: 0;
}
.sidebar-logout:hover {
  background: rgba(239,68,68,0.15);
  color: var(--danger);
}

/* ================================================
   MAIN CONTENT AREA
   ================================================ */

.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.page-header {
  background: var(--nav-bg);
  border-bottom: var(--border);
  padding: 0 32px;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
}

.page-title {
  font-size: 1.1rem;
  font-weight: 700;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.page-body {
  padding: 32px;
  flex: 1;
}

/* ================================================
   CARDS & SURFACES
   ================================================ */

.card {
  background: var(--surface);
  border: var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.card:hover { border-color: rgba(255,0,0,0.2); }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.card-title {
  font-size: 0.95rem;
  font-weight: 700;
}

.card-subtitle {
  font-size: 0.8rem;
  color: var(--muted-text);
  margin-top: 2px;
}

/* ================================================
   STAT CARDS
   ================================================ */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border: var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  overflow: hidden;
  transition: all 0.25s ease;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--stat-accent, var(--main-color-1));
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-md);
  background: var(--stat-icon-bg, rgba(255,0,0,0.12));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--stat-accent, var(--main-color-1));
  font-size: 20px;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 1.8rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.03em;
}

.stat-label {
  font-size: 0.78rem;
  color: var(--muted-text);
  font-weight: 500;
}

/* ================================================
   INTEGRATIONS SECTION
   ================================================ */

.integrations-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.integration-card {
  background: var(--surface);
  border: var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all 0.25s ease;
}

.integration-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.integration-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}

.integration-icon.discord { background: rgba(88,101,242,0.15); color: var(--discord-color); }
.integration-icon.stripe  { background: rgba(99,91,255,0.15);  color: var(--stripe-color);  }

.integration-body { flex: 1; }
.integration-name { font-weight: 700; font-size: 0.95rem; }
.integration-status {
  font-size: 0.78rem;
  color: var(--muted-text);
  margin-top: 2px;
}
.integration-status.linked { color: var(--success); }

/* ================================================
   SERVICES TABLE
   ================================================ */

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted-text);
  border-bottom: var(--border);
}

.data-table td {
  padding: 14px;
  border-bottom: var(--border);
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }

.data-table tr:hover td { background: var(--surface-hover); }

/* ================================================
   BADGES / STATUS PILLS
   ================================================ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: capitalize;
}

.badge-active    { background: rgba(34,197,94,0.15);  color: var(--success); }
.badge-pending   { background: rgba(245,158,11,0.15); color: var(--warning); }
.badge-suspended { background: rgba(239,68,68,0.15);  color: var(--danger); }
.badge-cancelled { background: rgba(107,114,128,0.15);color: #6b7280; }
.badge-open      { background: rgba(59,130,246,0.15); color: var(--info); }
.badge-resolved  { background: rgba(34,197,94,0.15);  color: var(--success); }
.badge-in_progress { background: rgba(245,158,11,0.15); color: var(--warning); }
.badge-closed    { background: rgba(107,114,128,0.15);color: #6b7280; }
.badge-low       { background: rgba(34,197,94,0.15);  color: var(--success); }
.badge-medium    { background: rgba(245,158,11,0.15); color: var(--warning); }
.badge-high      { background: rgba(239,68,68,0.15);  color: var(--danger); }
.badge-critical  { background: rgba(239,68,68,0.25);  color: #ff6b6b; }

/* ================================================
   BUTTONS
   ================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  white-space: nowrap;
  text-decoration: none;
}

.btn-primary {
  background: var(--main-color-1);
  color: #fff;
}
.btn-primary:hover {
  background: #cc0000;
  transform: translateY(-1px);
  box-shadow: var(--shadow-red);
}

.btn-discord {
  background: var(--discord-color);
  color: #fff;
}
.btn-discord:hover {
  background: #4752c4;
  transform: translateY(-1px);
}

.btn-stripe {
  background: var(--stripe-color);
  color: #fff;
}
.btn-stripe:hover {
  background: #4f46e5;
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--muted-text);
  border: var(--border);
}
.btn-ghost:hover {
  background: var(--surface-hover);
  color: var(--text-color);
}

.btn-danger {
  background: rgba(239,68,68,0.12);
  color: var(--danger);
  border: 1px solid rgba(239,68,68,0.25);
}
.btn-danger:hover {
  background: var(--danger);
  color: #fff;
}

.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn .material-symbols-outlined { font-size: 18px; }

/* ================================================
   ALERTS / FLASH MESSAGES
   ================================================ */

.alert {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 20px;
}
.alert-success { background: rgba(34,197,94,0.1);  border: 1px solid rgba(34,197,94,0.3);  color: var(--success); }
.alert-error   { background: rgba(239,68,68,0.1);  border: 1px solid rgba(239,68,68,0.3);  color: var(--danger); }
.alert-info    { background: rgba(59,130,246,0.1); border: 1px solid rgba(59,130,246,0.3); color: var(--info); }

/* ================================================
   FORMS
   ================================================ */

.form-group { margin-bottom: 18px; }

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--muted-text);
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  background: var(--surface-2);
  border: var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  color: var(--text-color);
  font-size: 0.9rem;
  font-family: 'Poppins', sans-serif;
  transition: all 0.2s ease;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--main-color-1);
  box-shadow: 0 0 0 3px rgba(255,0,0,0.1);
}

.form-textarea { resize: vertical; min-height: 100px; }

.form-hint {
  font-size: 0.75rem;
  color: var(--dim-text);
  margin-top: 5px;
}

/* ================================================
   LOGIN PAGE
   ================================================ */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-color);
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute;
  top: -20%;
  right: -10%;
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(255,0,0,0.08) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

.login-page::after {
  content: '';
  position: absolute;
  bottom: -20%;
  left: -10%;
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(0,51,204,0.06) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

.login-box {
  width: 100%;
  max-width: 440px;
  position: relative;
  z-index: 1;
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo {
  width: 52px; height: 52px;
  object-fit: contain;
  margin-bottom: 16px;
}

.login-header h1 {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.login-header p {
  font-size: 0.85rem;
  color: var(--muted-text);
  margin-top: 6px;
}

.login-card {
  background: var(--surface);
  border: var(--border);
  border-radius: var(--radius-xl);
  padding: 32px;
  box-shadow: var(--shadow-md);
}

/* Tabs */
.auth-tabs {
  display: flex;
  background: var(--surface-2);
  border-radius: var(--radius-md);
  padding: 4px;
  margin-bottom: 24px;
  gap: 4px;
}

.auth-tab {
  flex: 1;
  text-align: center;
  padding: 8px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--muted-text);
  transition: all 0.2s ease;
  border: none;
  background: transparent;
}

.auth-tab.active {
  background: var(--main-color-1);
  color: #fff;
}

.auth-panel { display: none; }
.auth-panel.active { display: block; }

/* Divider */
.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--dim-text);
  font-size: 0.78rem;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-color);
}

.login-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 0.8rem;
  color: var(--muted-text);
}

.login-footer a { color: var(--main-color-1); font-weight: 600; }

/* ================================================
   EMPTY STATE
   ================================================ */

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--muted-text);
}

.empty-state .material-symbols-outlined {
  font-size: 48px;
  color: var(--dim-text);
  margin-bottom: 12px;
  display: block;
}

.empty-state h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-color);
  margin-bottom: 6px;
}

.empty-state p { font-size: 0.83rem; }

/* ================================================
   PAGE GRID HELPERS
   ================================================ */

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
.mb-4   { margin-bottom: 16px; }
.mb-6   { margin-bottom: 24px; }
.mb-8   { margin-bottom: 32px; }
.flex   { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-2  { gap: 8px; }
.gap-3  { gap: 12px; }

/* ================================================
   MODE TOGGLE
   ================================================ */

.mode-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: var(--border);
  color: var(--muted-text);
  cursor: pointer;
  transition: all 0.2s ease;
}

.mode-toggle:hover {
  background: rgba(255,0,0,0.1);
  color: var(--main-color-1);
}

.mode-toggle .material-symbols-outlined { font-size: 18px; }

/* ================================================
   MOBILE MENU TOGGLE
   ================================================ */

.mobile-sidebar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  border: var(--border);
  cursor: pointer;
  color: var(--text-color);
}

/* ================================================
   RESPONSIVE
   ================================================ */

@media (max-width: 1024px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  :root { --sidebar-width: 260px; }

  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-md);
  }

  .sidebar.open { transform: translateX(0); }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 199;
    backdrop-filter: blur(2px);
  }

  .sidebar-overlay.show { display: block; }

  .main-content { margin-left: 0; }

  .mobile-sidebar-toggle { display: flex; }

  .page-body { padding: 16px; }

  .stats-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .login-card { padding: 24px 20px; }
}