/**
 * Utility Seva — Marks Percentage Calculator Stylesheet
 * Strict Compact UI Layout (< 768px desktop screen height compliance)
 * Fully responsive across desktop, tablet, and mobile with Dark Mode support
 */

/* ==========================================================================
   1. Header & Navigation (Utility Seva Standard Header Integration)
   ========================================================================== */
.site-header .nav-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-shrink: 0;
}

.site-header .theme-toggle-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background-color: var(--bg-surface);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
}

.site-header .theme-toggle-btn:hover {
  background-color: var(--bg-surface-alt);
  color: var(--text-primary);
  border-color: var(--border-color-hover);
}

.site-header .theme-toggle-btn svg {
  width: 20px;
  height: 20px;
  display: block;
  flex-shrink: 0;
  margin: auto;
  stroke: currentColor;
  stroke-width: 2;
  transition: transform var(--transition-fast), opacity var(--transition-fast);
}

.site-header .theme-toggle-btn .sun-icon {
  display: none;
}

.site-header .theme-toggle-btn .moon-icon {
  display: block;
}

html[data-theme="dark"] .site-header .theme-toggle-btn .sun-icon,
html.dark .site-header .theme-toggle-btn .sun-icon {
  display: block;
}

html[data-theme="dark"] .site-header .theme-toggle-btn .moon-icon,
html.dark .site-header .theme-toggle-btn .moon-icon {
  display: none;
}

/* ==========================================================================
   2. Main Container & Top Bar
   ========================================================================== */
.converter-main {
  min-height: calc(100vh - var(--nav-height) - 80px);
  padding: 0.5rem 0 1.25rem 0;
  background-color: var(--bg-body, var(--bg-primary));
}

.converter-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.45rem;
}

.breadcrumb-nav-compact {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.775rem;
  color: var(--text-muted);
  margin-bottom: 0.1rem;
}

.breadcrumb-nav-compact a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.breadcrumb-nav-compact a:hover {
  color: var(--brand-600);
}

.converter-title-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.converter-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  letter-spacing: -0.015em;
  line-height: 1.2;
}

.tool-badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.12rem 0.48rem;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  background-color: rgba(16, 185, 129, 0.12);
  color: var(--success, #10b981);
  border: 1px solid rgba(16, 185, 129, 0.25);
  line-height: 1.3;
}

.converter-subtitle {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin: 0.1rem 0 0 0;
  line-height: 1.3;
}

/* Alert Notification Banner */
.converter-alert {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.75rem;
  margin-bottom: 0.5rem;
  border-radius: var(--radius-md);
  background-color: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: #ef4444;
  font-size: 0.78rem;
  font-weight: 500;
  animation: fadeIn 0.2s ease;
}

.converter-alert svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* ==========================================================================
   3. Mode Switcher Controls Bar
   ========================================================================== */
.calc-controls-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.45rem 0.75rem;
  margin-bottom: 0.75rem;
  box-shadow: var(--shadow-sm);
}

.calc-tabs-group {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.calc-tab-btn {
  padding: 0.28rem 0.65rem;
  font-size: 0.76rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.calc-tab-btn:hover {
  background-color: var(--bg-surface-alt);
  color: var(--text-primary);
}

.calc-tab-btn.active {
  background-color: var(--brand-50, #eff6ff);
  color: var(--brand-600);
  border-color: rgba(99, 102, 241, 0.25);
}

html[data-theme="dark"] .calc-tab-btn.active,
html.dark .calc-tab-btn.active {
  background-color: rgba(99, 102, 241, 0.18);
  color: #a5b4fc;
}

.calc-quick-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ==========================================================================
   4. Main Workspace: Two Columns (1366x768 Desktop Viewport Target)
   ========================================================================== */
.marks-workspace-grid {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 0.85rem;
  margin-bottom: 0.85rem;
  align-items: start;
}

/* Shared Card Container */
.marks-panel-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 0.75rem 0.85rem;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-card);
  transition: border-color var(--transition-fast), background-color var(--transition-normal);
}

.panel-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border-color);
}

.panel-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.panel-title svg {
  width: 16px;
  height: 16px;
  color: var(--brand-500);
}

.panel-header-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.btn-ghost-sm {
  padding: 0.18rem 0.5rem;
  font-size: 0.72rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-ghost-sm:hover {
  background-color: var(--bg-surface-alt);
  color: var(--text-primary);
  border-color: var(--border-color-hover);
}

/* ==========================================================================
   5. Left Column: Subject Marks Input Table & Direct Mode
   ========================================================================== */
.table-scroll-container {
  max-height: 380px;
  min-height: 220px;
  overflow-y: auto;
  overflow-x: hidden;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: var(--bg-surface);
  margin-bottom: 0.5rem;
}

.marks-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.marks-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background-color: var(--bg-surface-alt);
  color: var(--text-secondary);
  font-weight: 600;
  text-align: left;
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.marks-table td {
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

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

.marks-table tr:hover td {
  background-color: rgba(99, 102, 241, 0.03);
}

.row-num-badge {
  display: inline-block;
  width: 20px;
  height: 20px;
  line-height: 20px;
  text-align: center;
  border-radius: var(--radius-full);
  background-color: var(--bg-surface-alt);
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 700;
}

.table-input {
  width: 100%;
  padding: 0.28rem 0.45rem;
  font-size: 0.78rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background-color: var(--bg-surface);
  color: var(--text-primary);
  outline: none;
  transition: all var(--transition-fast);
}

.table-input:focus {
  border-color: var(--brand-500);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

.table-input.invalid-input {
  border-color: #ef4444;
  background-color: rgba(239, 68, 68, 0.05);
}

.btn-row-del {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-row-del:hover:not(:disabled) {
  color: #ef4444;
  background-color: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.2);
}

.btn-row-del:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

.btn-row-del svg {
  width: 14px;
  height: 14px;
}

/* Direct Mode Card Form */
.direct-mode-form {
  padding: 1.25rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 0.5rem;
}

.direct-input-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.direct-input-label {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.direct-input-lg {
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background-color: var(--bg-surface-alt);
  color: var(--text-primary);
  outline: none;
  transition: all var(--transition-fast);
}

.direct-input-lg:focus {
  border-color: var(--brand-500);
  background-color: var(--bg-surface);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.direct-input-lg.invalid-input {
  border-color: #ef4444;
  background-color: rgba(239, 68, 68, 0.05);
}

/* Table Footer Actions */
.table-footer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn-add-row {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  font-size: 0.76rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  background-color: var(--brand-50, #eff6ff);
  color: var(--brand-600);
  border: 1px dashed var(--brand-500);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-add-row:hover {
  background-color: var(--brand-600);
  color: #ffffff;
  border-style: solid;
}

html[data-theme="dark"] .btn-add-row,
html.dark .btn-add-row {
  background-color: rgba(99, 102, 241, 0.12);
  color: #a5b4fc;
}

html[data-theme="dark"] .btn-add-row:hover,
html.dark .btn-add-row:hover {
  background-color: var(--brand-600);
  color: #ffffff;
}

.btn-add-row svg {
  width: 14px;
  height: 14px;
}

.table-stats-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* ==========================================================================
   6. Right Column: Percentage Result, Progress Bar & Analytics
   ========================================================================== */
.right-result-column {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

/* Status Pill */
.status-pill-badge {
  padding: 0.12rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  background-color: var(--bg-surface-alt);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

.status-pill-badge.active {
  background-color: rgba(16, 185, 129, 0.12);
  color: #10b981;
  border-color: rgba(16, 185, 129, 0.3);
}

/* Hero Percentage Result Box */
.hero-percentage-banner {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.1) 0%, rgba(16, 185, 129, 0.08) 100%);
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: var(--radius-md);
  padding: 0.75rem 0.95rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.percentage-score-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.percentage-score-group {
  display: flex;
  flex-direction: column;
}

.percentage-score-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.percentage-score-val {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--brand-600);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  margin-top: 0.1rem;
}

html[data-theme="dark"] .percentage-score-val,
html.dark .percentage-score-val {
  color: #818cf8;
}

.percentage-meta-badges {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.3rem;
}

.grade-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.6rem;
  font-size: 0.74rem;
  font-weight: 700;
  border-radius: var(--radius-full);
  background-color: rgba(16, 185, 129, 0.14);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

/* Visual Progress Bar */
.progress-bar-wrap {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.progress-track {
  width: 100%;
  height: 8px;
  background-color: var(--bg-surface-alt);
  border-radius: var(--radius-full);
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.progress-fill {
  height: 100%;
  width: 0%;
  max-width: 100%;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, #6366f1 0%, #10b981 100%);
  transition: width 0.3s cubic-bezier(0.16, 1, 0.3, 1), background 0.3s ease;
}

.progress-fill.fill-warn {
  background: linear-gradient(90deg, #f59e0b 0%, #ef4444 100%);
}

.progress-labels-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.66rem;
  color: var(--text-muted);
}

/* Key Stats Grid */
.marks-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.45rem;
}

.stat-item-box {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.45rem 0.55rem;
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.stat-val {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 0.1rem;
  font-variant-numeric: tabular-nums;
}

/* Action Buttons Bar */
.action-buttons-bar {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.1rem;
  flex-wrap: wrap;
}

.btn-action-primary {
  flex: 1.2;
  min-width: 120px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.42rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  background-color: var(--brand-600);
  color: #ffffff;
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: 0 1px 2px rgba(79, 70, 229, 0.25);
}

.btn-action-primary:hover:not(:disabled) {
  background-color: var(--brand-700);
  transform: translateY(-1px);
}

.btn-action-secondary {
  flex: 1;
  min-width: 120px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.42rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  background-color: var(--bg-surface-alt);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-action-secondary:hover:not(:disabled) {
  background-color: var(--border-color);
}

.btn-action-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.42rem 0.65rem;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-action-ghost:hover:not(:disabled) {
  background-color: var(--bg-surface-alt);
  color: var(--text-primary);
}

.btn-action-primary svg,
.btn-action-secondary svg,
.btn-action-ghost svg {
  width: 14px;
  height: 14px;
}

/* Floating Toast Notification */
.copy-feedback-toast {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.65rem;
  background-color: #0f172a;
  color: #ffffff;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: toastFade 0.25s ease;
  margin-top: 0.2rem;
  align-self: flex-start;
}

html[data-theme="dark"] .copy-feedback-toast,
html.dark .copy-feedback-toast {
  background-color: #f8fafc;
  color: #0f172a;
}

@keyframes toastFade {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Grade Bands Card & Editable Table */
.grade-bands-card {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: var(--bg-surface);
  padding: 0.5rem 0.65rem;
  margin-top: 0.2rem;
}

.grade-bands-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.35rem;
}

.grade-bands-title {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.grade-bands-title svg {
  width: 13px;
  height: 13px;
  color: var(--brand-500);
}

.grade-bands-table {
  width: 100%;
  font-size: 0.68rem;
  border-collapse: collapse;
}

.grade-bands-table th, .grade-bands-table td {
  padding: 0.2rem 0.35rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.grade-bands-table th {
  color: var(--text-muted);
  font-weight: 600;
}

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

.grade-band-input {
  width: 45px;
  padding: 0.1rem 0.25rem;
  font-size: 0.68rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background-color: var(--bg-surface-alt);
  color: var(--text-primary);
  text-align: center;
}

/* ==========================================================================
   7. Educational Guide Section (Below Workspace)
   ========================================================================== */
.educational-guide-section {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

.guide-grid-3col {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.85rem;
}

.guide-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 0.85rem;
  box-shadow: var(--shadow-card);
}

.guide-card-header {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.4rem;
}

.guide-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-md);
  background-color: rgba(99, 102, 241, 0.12);
  color: var(--brand-600);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.guide-icon svg {
  width: 15px;
  height: 15px;
}

.guide-card-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.guide-card p {
  font-size: 0.74rem;
  color: var(--text-secondary);
  line-height: 1.45;
  margin: 0;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   8. Responsive Media Queries
   ========================================================================== */
@media (max-width: 960px) {
  .marks-workspace-grid {
    grid-template-columns: 1fr;
  }

  .table-scroll-container {
    max-height: 320px;
  }

  .guide-grid-3col {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .converter-title {
    font-size: 1.15rem;
  }

  .calc-controls-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .action-buttons-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .marks-stats-grid {
    grid-template-columns: 1fr;
  }

  .percentage-score-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .percentage-meta-badges {
    align-items: flex-start;
  }
}

