/* Reset and base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  display: flex;
  flex-direction: column;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100svh;
  color: #333;
  line-height: 1.6;
}

/* Container: don't center content when side panel is visible */
.container {
    flex: 1 1 auto;
    display: flex;
    flex-direction: row;
    align-items: stretch;
    justify-content: flex-start;
    position: relative; /* make children positionable relative to the container */
    overflow: hidden;   /* prevent internal scrolling visuals for the container */
    padding: 2rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 0;
}

body:not(.with-side-panel) .container {
    justify-content: center;
    align-items: center;
}

/* Mobile menu toggle button (floating in container) */
#menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.75rem; /* nice large icon size for mobile */
    color: #4a5568;
    cursor: pointer;
    padding: 0.25rem;
    margin: 0;
    line-height: 1;
}

#menu-toggle:hover {
    color: #667eea;
}

.altcha-wrapper {
  display: flex;
  justify-content: center;
}

/* Header adjustments (none specific; menu toggle lives in container) */

/* Authentication Section */
.auth-section {
  width: 100%;
  max-width: 400px;
}

.auth-card {
  background: white;
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
  padding: 2.5rem;
  text-align: center;
}

.auth-card h1 {
  color: #2d3748;
  margin-bottom: 0.5rem;
  font-size: 2rem;
  font-weight: 700;
}

.subtitle {
  color: #718096;
  margin-bottom: 2rem;
  font-size: 0.95rem;
}

.auth-form {
  text-align: left;
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  color: #4a5568;
  font-weight: 500;
  font-size: 0.9rem;
}

.form-group input {
  width: 100%;
  padding: 0.75rem;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  font-size: 1rem;
  transition: border-color 0.2s ease;
}

.form-group input:focus {
  outline: none;
  border-color: #667eea;
}

.form-footer {
  margin-top: 20px;
  text-align: center;
}

.footer-lang-switch {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  flex-wrap: wrap; /* allows wrapping if screen too narrow */
}

.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  padding: 0.75rem;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.btn-primary:hover {
  transform: translateY(-1px);
}

.btn-primary:disabled {
  background: #cbd5e0;
  color: #a0aec0;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  background: #f7fafc;
  color: #4a5568;
  border: 2px solid #e2e8f0;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: #edf2f7;
  border-color: #cbd5e0;
}

/* Dashboard Section */
.dashboard-section {
    width: 100%;
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    display: flex;
    position: relative;
    min-height: 600px;
    overflow-y: auto;         /* main content scrolls, not the container */
}

/* Mobile menu button is positioned inside container by default */

/* Side panel: anchored to container's upper-left, spans full container height */
.side-panel {
    display: none;            /* hidden before login */
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;             /* fill the container's height */
    width: 280px;             /* fixed width */
    background: #ffffff;
    border-right: 1px solid #e2e8f0;
    box-shadow: 2px 0 10px rgba(0,0,0,0.04);
    z-index: 1;               /* sit above background, below content layer if needed */
    overflow: auto;           /* menu itself can scroll if its content exceeds container height */
    flex-direction: column;
}

/* Show side panel only when logged in */
body.with-side-panel .side-panel {
    display: flex;
}

/* Shift main content to the right of the fixed-width menu when visible */
body.with-side-panel #dashboard-section {
    margin-left: 280px;       /* equals side-panel width */
}

/* Removed nav group styling (no side-panel instruction group) */

/* Removed explicit close button styling */

.nav-tab,
.nav-subtab {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.875rem 1.5rem;
  border: none;
  background: transparent;
  color: #4a5568;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}

.nav-tab:hover,
.nav-subtab:hover {
  background: #edf2f7;
  color: #2d3748;
}

.nav-tab.active,
.nav-subtab.active {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.nav-tab svg {
  width: 20px;
  height: 20px;
}
.side-panel-header {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.side-panel-header h2 {
    color: #2d3748;
    font-size: 1rem;
    font-weight: 600;
}

/* Menu items */
.side-panel-nav {
    padding: 0.5rem 0;
    /* no flex:1 to keep logout button directly after nav items */
}

.side-panel-footer {
    padding: 0.75rem 1rem;
    border-top: 1px solid #e2e8f0;
    margin-top: 0.5rem;
}

.side-panel-footer .btn-secondary {
    width: 100%;
    justify-content: center;
}

/* Main content area */
.main-content {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

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

.tab-header h1 {
  color: #2d3748;
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.tab-header p {
  color: #718096;
}

/* Configuration Tab Styles */
.config-container {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  margin-top: 2rem;
}

.config-section {
  background: #f7fafc;
  border-radius: 8px;
  padding: 1.5rem;
}

.config-section h3 {
  color: #2d3748;
  margin-bottom: 1rem;
  font-size: 1.1rem;
  font-weight: 600;
}

.json-container {
  position: relative;
}

.json-container pre {
  background: #2d3748;
  color: #e2e8f0;
  padding: 1rem;
  border-radius: 6px;
  font-size: 0.85rem;
  line-height: 1.4;
  max-height: 400px;
  overflow-y: auto;
  margin-bottom: 1rem;
  white-space: pre-wrap;
  word-break: break-all;
}

.qr-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

#qr-code {
  margin-bottom: 1rem;
}

#qr-code canvas {
  max-width: 100%;
  height: auto;
}

/* Billing Tab Styles */
.billing-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.billing-card {
  background: #f7fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 2rem;
}

.billing-card h3 {
  color: #2d3748;
  margin-bottom: 1.5rem;
  font-size: 1.2rem;
  font-weight: 600;
}

.plan-status {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.plan-info {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.plan-type {
  font-size: 1.25rem;
  font-weight: 600;
  color: #2d3748;
  text-transform: capitalize;
}

.plan-status-badge {
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
}

.plan-status-badge.active {
  background: #c6f6d5;
  color: #22543d;
}

.plan-status-badge.trial {
  background: #fbd38d;
  color: #975a16;
}

.plan-status-badge.expired {
  background: #fed7d7;
  color: #c53030;
}

.plan-dates {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-size: 0.95rem;
}

.plan-dates p {
  display: flex;
  flex-direction: row;
  gap: 0.25rem;
  align-items: baseline;
  margin: 0;
}

.payment-section {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.payment-info {
  text-align: center;
}

.payment-amount {
  font-size: 2rem;
  font-weight: 700;
  color: #2d3748;
  margin-bottom: 0.5rem;
}

.payment-description {
  color: #718096;
  font-size: 0.95rem;
}

.payment-btn {
  align-self: center;
  width: auto;
  min-width: 200px;
  padding: 1rem 2rem;
  font-size: 1.1rem;
}

.payment-status {
  padding: 1rem;
  border-radius: 8px;
  text-align: center;
  font-size: 0.95rem;
  font-weight: 500;
}

.payment-status.info {
  background: #bee3f8;
  color: #2a4365;
}

.payment-status.warning {
  background: #fbd38d;
  color: #975a16;
}

.payment-status.success {
  background: #c6f6d5;
  color: #22543d;
}

/* Error Messages */
.error-message {
  background: #fed7d7;
  color: #c53030;
  padding: 0.75rem;
  border-radius: 6px;
  margin-top: 1rem;
  font-size: 0.9rem;
  white-space: pre-wrap;
}

/* Loading states */
.loading {
  opacity: 0.6;
  pointer-events: none;
}

/* Success feedback */
.copy-success {
  background: #c6f6d5;
  color: #22543d;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  font-size: 0.8rem;
  margin-top: 0.5rem;
  display: inline-block;
}

.support-bar {
  bottom: 0;
  left: 0;
  width: 100%;
  background: white;
  color: #718096;
  text-align: center;
  padding: 0.75rem;
  font-size: 0.9rem;
  border-top: 1px solid #e2e8f0;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
  z-index: 1000;
}

.support-bar a {
  color: #667eea;
  text-decoration: none;
  font-weight: 500;
}

.support-bar a:hover {
  text-decoration: underline;
}

.top-header {
  width: 100%;
  background: white;
  border-bottom: 1px solid #e2e8f0;
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 4px 8px rgba(0,0,0,0.03);
  top: 0;
  z-index: 999;
}

body.with-side-panel .top-header {
    justify-content: flex-start;
    gap: 1.5rem;
}

.logo-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-img {
  height: 60px;
  width: 60px;
  object-fit: cover;
  border-radius: 6px;
}

.logo-text {
  font-size: 1.4rem;
  font-weight: 700;
  color: #2d3748;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

/* Dropdown */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropbtn {
  background: none;
  border: none;
  color: #4a5568;
  font-size: 1rem;
  cursor: pointer;
  font-weight: 500;
  margin: 1rem;
}

.dropdown-content {
  display: none;
  position: absolute;
  background-color: white;
  box-shadow: 0 4px 8px rgba(0,0,0,0.08);
  min-width: 160px;
  z-index: 1000;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
}

body a {
    text-decoration: none;
}

.dropdown-content a {
  color: #4a5568;
  padding: 0.75rem 1rem;
  text-decoration: none;
  display: block;
  font-size: 0.95rem;
}

.dropdown-content a:hover {
  background-color: #f7fafc;
}

.dropdown:hover .dropdown-content {
  display: block;
}

.lang-btn {
  background: white;
  border: 1px solid #ccc;
  padding: 4px 8px;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  border-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
  white-space: nowrap;
}

/* Markdown Content Styling */
.markdown-section {
  background: white;
  border-radius: 12px;
  padding: 2rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.08);
  color: #2d3748;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  line-height: 1.7;
  font-size: 1rem;
  width: 100%;
  margin-bottom: 2rem;
}

/* Markdown Headings */
.markdown-section h1,
.markdown-section h2,
.markdown-section h3 {
  color: #2d3748;
  margin: 1.5rem 0 1rem;
  font-weight: 600;
}

.markdown-section h1 {
  font-size: 2rem;
}
.markdown-section h2 {
  font-size: 1.5rem;
}
.markdown-section h3 {
  font-size: 1.25rem;
}

/* Markdown Text Elements */
.markdown-section p {
  margin-bottom: 1rem;
  color: #4a5568;
}

.markdown-section strong {
  font-weight: 600;
  color: #2d3748;
}

.markdown-section em {
  font-style: italic;
  color: #555;
}

.markdown-section ul,
.markdown-section ol {
  margin-left: 1.5rem;
  margin-bottom: 1rem;
}

.markdown-section ul li,
.markdown-section ol li {
  margin-bottom: 0.5rem;
}

.markdown-section a {
  color: #5a3ec8;
  font-weight: 600;
  text-decoration: underline;
  transition: color 0.2s;
}

.markdown-section a:hover {
  color: #764ba2;
  text-decoration: underline;
}

/* Markdown Code Blocks */
.markdown-section code {
  background-color: #f7fafc;
  border: 1px solid #e2e8f0;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.95rem;
}

.markdown-section pre code {
  background: #2d3748;
  color: #e2e8f0;
  padding: 1rem;
  display: block;
  border-radius: 6px;
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.5;
}

/* Markdown Blockquotes */
.markdown-section blockquote {
  border-left: 4px solid #667eea;
  padding-left: 1rem;
  margin: 1rem 0;
  color: #4a5568;
  font-style: italic;
  background: #f7fafc;
  border-radius: 4px;
}

/* Markdown Tables */
.markdown-section table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.95rem;
}

.markdown-section th,
.markdown-section td {
  border: 1px solid #e2e8f0;
  padding: 0.75rem 1rem;
  text-align: left;
}

.markdown-section th {
  background: #edf2f7;
  font-weight: 600;
  color: #2d3748;
}

.markdown-section img {
  max-width: 600px;
  width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 1rem auto;
  display: block;
}

.markdown-section img[src*="/android/"],
.markdown-section img[src*="/ios/"] {
  max-width: 300px;
  width: auto;
}

#main-nav-wrapper {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}

/* Responsive Design */
@media (max-width: 768px) {
  .container {
    padding: 1rem;
  }
  
  .auth-card {
    padding: 2rem;
  }
  
  .config-container {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  /* No header-specific visibility rules after revert */

  .dashboard-section {
    flex-direction: column;
    min-height: auto;
  }

  .side-panel {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    transform: translateX(-100%);
    z-index: 1000;
  }

  .side-panel.open {
    transform: translateX(0);
  }

  .side-panel-overlay.open {
    display: block;
  }

  /* No explicit close button */

  .main-content {
    padding: 4rem 1.5rem 1.5rem;
  }
}

.logo-link {
    text-decoration: none;
    display: flex;
    align-items: center;
}

@media (max-width: 480px) {
  .top-header {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.75rem;
    padding: 0.5rem;
  }

    body.with-side-panel .top-header {
        flex-direction: row;
        justify-content: flex-start;
    }

    #menu-toggle {
        margin-left: 1rem;
    }

  #main-nav-wrapper {
    width: 100%;
  }

  .hide-on-mobile {
    display: none;
  }

  .logo-title {
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
  }

  .logo-img {
    height: 50px;
    width: 50px;
  }

  .main-nav {
    flex-direction: column;
    align-items: center;
    width: 100%;
    gap: 0.5rem;
  }

  .btn-primary,
  .btn-secondary {
    width: 100%;
    font-size: 1rem;
    padding: 0.6rem 1rem;
    box-sizing: border-box;
  }

  .auth-card {
    padding: 1rem;
    width: 100%;
    max-width: 90%;
    margin: 1rem auto;
    box-sizing: border-box;
  }

  .auth-card h1 {
    font-size: 1.5rem;
  }

  .auth-form input {
    font-size: 1rem;
    padding: 0.6rem;
  }

  .form-group label {
    font-size: 0.9rem;
  }

  .dropdown-content {
    text-align: left;
  }

  .support-bar {
    font-size: 0.75rem;
    padding: 0.75rem 0.5rem;
    line-height: 1.4;
    text-align: center;
  }

  .support-bar a {
    display: inline-block;
    word-break: break-word;
    max-width: 100%;
  }

  .container {
    padding: 1.5rem 1rem;
  }

  .lang-btn {
    font-size: 0.75rem;
    padding: 4px 6px;
  }

  .auth-card h1 {
    font-size: 1.25rem;
  }

  .subtitle {
    margin-bottom: 1rem;
  }

  .form-group {
    margin-bottom: 1rem;
  }

  .form-footer {
    margin-top: 10px;
  }
}

/* Overlay behind the side panel in mobile mode (full screen, dims everything) */
#mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;                 /* top:0; right:0; bottom:0; left:0 */
    background: rgba(0,0,0,0.5);
    z-index: 9990;            /* below panel, above everything else */
}

body.with-side-panel #instructions-section {
    margin-left: 280px;
}

/* Narrow screens: make the side panel a full-screen overlay drawer */
@media (max-width: 900px) {
    /* Ensure content uses full width and doesn't shift */
    body.with-side-panel #dashboard-section {
        margin-left: 0;
    }

    body.with-side-panel #instructions-section {
        margin-left: 0;
    }

    /* Full-screen drawer above header/footer */
    .side-panel {
        position: fixed;
        top: 0;                 /* overlay from very top of viewport */
        left: 0;
        height: 100vh;          /* full screen height */
        width: 280px;           /* drawer width */
        box-shadow: 12px 0 30px rgba(0,0,0,0.2);
        z-index: 9991;          /* above overlay */
        overflow-y: auto;
        background: #ffffff;
        border-right: 1px solid #e2e8f0;
        /* Start hidden with no animation */
        transform: translateX(-100%);
        /*transition: none;*/
        transition: transform 0.25s ease-in-out;
    }

    body.mobile-menu-open .side-panel {
        /* Only animate when opening */
        transform: translateX(0);
        /*transition: transform 0.25s ease-in-out;*/
    }

    body.mobile-menu-open #mobile-overlay {
        display: block;
    }

    /* Show the menu toggle button when logged in */
    body.with-side-panel #menu-toggle {
        display: inline-block;
    }

    body.no-transitions .side-panel {
        transition: none !important;
    }
}

/* Arrow rotation */
.nav-tab .arrow {
    transition: transform 0.3s ease;
}
.nav-tab .arrow.rotated {
    transform: rotate(90deg);
}

/* Smooth submenu slide in */
.instruction-submenu {
    transition: max-height 0.3s ease, opacity 0.3s ease;
    overflow: hidden;
    max-height: 0;
    opacity: 0;
}

.instruction-submenu.submenu-slide-in {
    max-height: 500px; /* enough to fit content */
    opacity: 1;
}

/* Payment actions layout under USDT field */
.payment-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 0.5rem;
}
.payment-actions .btn-primary,
.payment-actions .btn-secondary {
  width: auto;
  min-width: 180px;
}
