/* ==========================================================================
   TeleStorage SaaS Dashboard Design System (Operate Mode)
   High-density, dark slate aesthetic for commercial infrastructure software
   ========================================================================== */

:root {
  /* Color Palette */
  --bg-primary: #090d16;
  --bg-canvas: #090d16;
  --bg-surface: #0f172a;
  --bg-card: #1e293b;
  --bg-input: #0b1120;
  --bg-hover: #334155;

  --border: rgba(255, 255, 255, 0.08);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-focus: #3b82f6;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent: #3b82f6;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-glow: rgba(59, 130, 246, 0.2);

  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-danger: #ef4444;

  /* Typography */
  --font-sans: 'Vazirmatn', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Consolas, monospace;

  /* Metrics & Elevation */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
  --shadow-modal: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

@import url('https://cdn.jsdelivr.net/gh/rastikerdar/vazirmatn@v33.003/Vazirmatn-font-face.css');

/* Reset & Global Vazirmatn Font Enforcement */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Vazirmatn', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
}

body, button, input, select, textarea, optgroup, table, th, td, div, span, p, h1, h2, h3, h4, h5, h6, label, a, .btn, .form-control, .search-input, .modal, .toast, .brand-name, .nav-link, .tab-btn, dialog, ::placeholder, input::placeholder, textarea::placeholder {
  font-family: 'Vazirmatn', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
}

code, pre, .mono, .hash-text, .mono-text {
  font-family: var(--font-mono), monospace !important;
}

body {
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  line-height: 1.6;
  direction: rtl;
  text-align: right;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  padding: 0 24px;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  color: var(--primary);
  display: flex;
  align-items: center;
}

.brand-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-name {
  font-weight: 700;
  font-size: 1.125rem;
  letter-spacing: -0.02em;
}

.brand-badge {
  font-size: 0.75rem;
  background: rgba(59, 130, 246, 0.15);
  color: var(--primary);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-weight: 600;
}

.topbar-status {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  padding: 6px 14px;
  border-radius: 9999px;
  font-size: 0.8125rem;
  cursor: pointer;
  border: 1px solid var(--border-subtle);
  transition: border-color var(--transition-fast);
}

.topbar-status:hover {
  border-color: var(--primary);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.status-dot.green { background-color: var(--color-success); box-shadow: 0 0 8px var(--color-success); }
.status-dot.amber { background-color: var(--color-warning); box-shadow: 0 0 8px var(--color-warning); }
.status-dot.red { background-color: var(--color-danger); box-shadow: 0 0 8px var(--color-danger); }

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--transition-fast);
}

.nav-link:hover {
  color: var(--text-primary);
  background-color: var(--bg-hover);
}

.nav-link.active {
  color: var(--text-primary);
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 16px;
}

.user-badge-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-tier-pill {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  background-color: var(--primary);
  color: #fff;
  text-transform: uppercase;
}

.user-email {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* App Container */
.app-container {
  flex: 1;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 32px 24px;
}

.view-panel {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
  padding: 8px 16px;
  font-size: 0.875rem;
}

.btn-primary { background-color: var(--primary); color: #fff; }
.btn-primary:hover { background-color: var(--primary-hover); }

.btn-secondary { background-color: var(--bg-card); color: var(--text-primary); border-color: var(--border-subtle); }
.btn-secondary:hover { background-color: var(--bg-hover); }

.btn-subtle { background-color: transparent; color: var(--text-secondary); }
.btn-subtle:hover { color: var(--text-primary); background-color: var(--bg-hover); }

.btn-danger { background-color: var(--color-danger); color: #fff; }
.btn-danger:hover { opacity: 0.9; }

.btn-sm { padding: 4px 10px; font-size: 0.8125rem; }
.btn-xs { padding: 2px 8px; font-size: 0.75rem; }
.btn-block { width: 100%; }

/* Form Controls */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.form-group label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-control {
  background-color: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.875rem;
  outline: none;
  transition: border-color var(--transition-fast);
}

.form-control:focus {
  border-color: var(--border-focus);
}

/* Auth Card */
.auth-card {
  max-width: 440px;
  margin: 60px auto;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 36px;
  box-shadow: var(--shadow-card);
}

.auth-header {
  text-align: center;
  margin-bottom: 24px;
}

.auth-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 8px;
}

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

.tab-switcher {
  display: flex;
  background-color: var(--bg-canvas);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 24px;
}

.tab-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: 8px;
  font-weight: 600;
  font-size: 0.875rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.tab-btn.active {
  background-color: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.tier-select-hint {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  background-color: var(--bg-card);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
}

/* OTP Components */
.otp-sent-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.25);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 0.875rem;
}

.otp-code-input {
  letter-spacing: 0.6rem !important;
  font-size: 1.5rem !important;
  text-align: center;
  font-weight: 700;
  direction: ltr;
}

.otp-timer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
  min-height: 32px;
}

.otp-edit-btn {
  color: var(--primary);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 2px 6px;
  text-decoration: underline;
}

.otp-edit-btn:hover {
  color: var(--primary-hover);
}

/* Drop Zone */
.drop-zone {
  background-color: var(--bg-surface);
  border: 2px dashed var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.drop-zone:hover, .drop-zone.is-dragover {
  border-color: var(--primary);
  background-color: rgba(59, 130, 246, 0.04);
}

.drop-zone-icon {
  color: var(--primary);
  margin-bottom: 12px;
}

.drop-zone h3 {
  font-size: 1.125rem;
  margin-bottom: 6px;
}

.drop-zone-hint {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* Upload Progress Card */
.upload-progress-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px 20px;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: 0.875rem;
}

.progress-file-meta {
  display: flex;
  gap: 12px;
  align-items: center;
}

.progress-file-meta .file-name {
  font-weight: 600;
}

.progress-file-meta .file-size {
  color: var(--text-secondary);
}

.progress-metrics {
  display: flex;
  gap: 14px;
  align-items: center;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.progress-track {
  height: 6px;
  background-color: var(--bg-card);
  border-radius: 9999px;
  overflow: hidden;
}

.progress-track.lg {
  height: 10px;
}

.progress-fill {
  height: 100%;
  background-color: var(--primary);
  transition: width 200ms ease-out;
}

.progress-fill.success { background-color: var(--color-success); }
.progress-fill.primary { background-color: var(--primary); }

/* Table */
.table-container {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  text-align: left;
}

.data-table th {
  background-color: var(--bg-card);
  color: var(--text-secondary);
  font-weight: 600;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border-subtle);
}

.data-table td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tr:hover td {
  background-color: rgba(255, 255, 255, 0.02);
}

.font-mono {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
}

.table-empty-state {
  text-align: center;
  padding: 60px 24px;
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 16px;
}

/* Toolbar */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.toolbar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  flex: 1;
  max-width: 360px;
}

.search-input {
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 0.875rem;
  width: 100%;
}

.toolbar-stats {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.toolbar-actions {
  display: flex;
  gap: 12px;
}

/* Quota & Billing Grid */
.usage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 24px;
}

.metric-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 24px;
}

.metric-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

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

.meter-details {
  display: flex;
  justify-content: space-between;
  margin-top: 12px;
  font-size: 0.875rem;
}

.meter-footer {
  margin-top: 14px;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* Tier Cards Grid */
.tier-cards-container {
  margin-top: 16px;
}

.section-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 18px;
}

.tier-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
}

.tier-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 28px;
  display: flex;
  flex-direction: column;
  position: relative;
  transition: transform var(--transition-fast);
}

.tier-card:hover {
  transform: translateY(-4px);
}

.tier-card.featured {
  border-color: var(--primary);
  box-shadow: 0 0 20px var(--primary-glow);
}

.tier-badge-featured {
  position: absolute;
  top: -12px;
  right: 20px;
  background-color: var(--primary);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 9999px;
  text-transform: uppercase;
}

.tier-name {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.tier-price {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 16px;
}

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

.tier-features {
  list-style: none;
  margin-bottom: 24px;
  flex: 1;
}

.tier-features li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.875rem;
  margin-bottom: 10px;
  color: var(--text-secondary);
}

.tier-features li::before {
  content: "✓";
  color: var(--color-success);
  font-weight: 700;
}

/* System Telemetry Grid */
.telemetry-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 24px;
}

.telemetry-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 24px;
}

.telemetry-card.highlight-card {
  border-right: 4px solid var(--primary);
  border-left: none;
}

.card-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.cb-pill {
  display: inline-block;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.875rem;
  margin-bottom: 16px;
}

.cb-pill.CLOSED { background-color: rgba(16, 185, 129, 0.15); color: var(--color-success); }
.cb-pill.HALF_OPEN { background-color: rgba(245, 158, 11, 0.15); color: var(--color-warning); }
.cb-pill.OPEN { background-color: rgba(239, 68, 68, 0.15); color: var(--color-danger); }

.metric-huge {
  font-size: 2.25rem;
  font-weight: 800;
  line-height: 1.1;
  color: var(--text-primary);
}

.telemetry-subtext {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.telemetry-rows {
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 0.875rem;
}

.telemetry-row {
  display: flex;
  justify-content: space-between;
}

.telemetry-row span { color: var(--text-secondary); }

/* Modals */
.modal-dialog {
  background: transparent;
  border: none;
  max-width: 520px;
  width: 90%;
  margin: auto;
  padding: 0;
}

.modal-dialog::backdrop {
  background-color: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
}

.modal-content {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 28px;
  box-shadow: var(--shadow-modal);
  color: var(--text-primary);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.modal-header h3 { font-size: 1.125rem; font-weight: 700; }

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
}

.modal-body { margin-bottom: 24px; }
.modal-description { font-size: 0.875rem; color: var(--text-secondary); margin-bottom: 16px; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.copy-input-group {
  display: flex;
  gap: 8px;
}

.copy-input-group input { flex: 1; }

.copy-feedback {
  font-size: 0.75rem;
  color: var(--color-success);
  margin-top: 4px;
  display: block;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 1000;
}

.toast {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-right: 4px solid var(--primary);
  border-left: none;
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  box-shadow: var(--shadow-card);
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 280px;
  animation: slideIn 200ms ease-out;
}

.toast.success { border-right-color: var(--color-success); border-left: none; }
.toast.error { border-right-color: var(--color-danger); border-left: none; }
.toast.warning { border-right-color: var(--color-warning); border-left: none; }

@keyframes slideIn {
  from { transform: translateX(-100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Thumbnail & Preview System */
.file-thumb-container {
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: var(--radius-sm);
  background-color: var(--bg-input);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
  margin: 0 auto;
}

.file-thumb-container:hover {
  transform: scale(1.08);
  border-color: var(--primary);
}

.file-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.file-thumb-icon {
  font-size: 1.3rem;
  user-select: none;
}

.file-name-cell {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.file-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.file-name-text {
  font-weight: 500;
  color: var(--text-primary);
  word-break: break-all;
}

.file-note-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background-color: rgba(59, 130, 246, 0.1);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 0.78rem;
  line-height: 1.4;
  margin-top: 4px;
  max-width: fit-content;
}

.action-btn-group {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-end;
}

.btn-icon-sm {
  padding: 5px 8px;
  font-size: 0.8rem;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Responsive Breakpoints */
@media (max-width: 768px) {
  .topbar { padding: 0 16px; }
  .topbar-nav { display: none; }
  .app-container { padding: 16px; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar-search { max-width: none; }
  .data-table th:nth-child(4), .data-table td:nth-child(4) { display: none; }
}
