/* ==========================================================================
   C-FAP Study Material Platform - Reusable UI Components
   Modern, Clean, Structured Accounting Elements & Tools
   ========================================================================== */

/* Tables - Financial, Ledger & Field Breakdown */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  margin: 1.75rem 0;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  box-shadow: var(--shadow-xs);
}

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

th {
  background: var(--bg-subtle);
  color: var(--text-primary);
  font-weight: 700;
  padding: 0.85rem 1.15rem;
  border-bottom: 2px solid var(--border-color);
  white-space: nowrap;
  letter-spacing: 0.01em;
}

td {
  padding: 0.85rem 1.15rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-secondary);
}

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

tr:hover td {
  background-color: rgba(37, 99, 235, 0.02);
}

[data-theme="dark"] tr:hover td {
  background-color: rgba(255, 255, 255, 0.02);
}

.text-right { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--font-mono); }
.text-center { text-align: center; }

/* Accounting Grand Total Row */
tr.grand-total td {
  font-weight: 700;
  color: var(--text-primary);
  background: var(--bg-subtle);
  border-top: 2px solid var(--border-color);
  border-bottom: 3px double var(--border-color);
}

/* Accounting Journal Entry Card */
.journal-entry-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  margin: 1.75rem 0;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.journal-header {
  background: var(--bg-subtle);
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--text-primary);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.journal-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 0.88rem;
}

.journal-table th {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  font-size: 0.78rem;
  text-transform: uppercase;
  color: var(--text-muted);
}

.journal-table td {
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
}

.journal-debit-row td:first-child {
  padding-left: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
}

.journal-credit-row td:first-child {
  padding-left: 2.5rem;
  color: var(--text-secondary);
}

.journal-narration {
  font-style: italic;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.86rem;
  padding: 0.65rem 1.25rem 0.85rem;
  background: var(--bg-subtle);
  border-top: 1px dashed var(--border-color);
}

.journal-logic-box {
  padding: 0.9rem 1.25rem;
  background: rgba(37, 99, 235, 0.04);
  border-top: 1px solid var(--border-color);
  font-size: 0.86rem;
  color: var(--text-secondary);
}

.journal-logic-box strong {
  color: var(--primary-light);
}

/* Tally Navigation Step Flow */
.tally-steps-container {
  margin: 1.75rem 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.tally-step-item {
  display: flex;
  gap: 1.25rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.15rem 1.4rem;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-xs);
}

.tally-step-item:hover {
  border-color: var(--primary-light);
  box-shadow: var(--shadow-sm);
  transform: translateX(3px);
}

.step-num-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  min-width: 32px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white;
  border-radius: var(--radius-full);
  font-weight: 700;
  font-size: 0.85rem;
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.25);
}

.step-body {
  flex: 1;
}

.step-title {
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.35rem;
  font-size: 0.98rem;
}

.step-nav-path {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.84rem;
  color: var(--text-primary);
  margin-top: 0.45rem;
}

.nav-arrow {
  color: var(--accent);
  font-weight: 700;
}

/* Keyboard Keycap Styling */
kbd {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--primary);
  background: linear-gradient(180deg, var(--bg-surface) 0%, var(--bg-subtle) 100%);
  border: 1px solid var(--border-subtle);
  border-bottom: 2px solid var(--border-subtle);
  border-radius: 5px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  line-height: 1.2;
}

[data-theme="dark"] kbd {
  color: #93c5fd;
  border-color: var(--border-color);
  background: var(--bg-subtle);
}

/* Process Flow Diagrams */
.flow-diagram {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.85rem;
  margin: 2rem 0;
  padding: 1.5rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow-x: auto;
  box-shadow: var(--shadow-xs);
}

.flow-node {
  flex: 1;
  min-width: 140px;
  text-align: center;
  padding: 1rem 0.85rem;
  background: var(--bg-subtle);
  border: 1.5px solid var(--primary-light);
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.86rem;
  color: var(--text-primary);
}

.flow-node.highlight {
  background: var(--primary-subtle);
  border-color: var(--primary);
}

.flow-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary-light);
  font-size: 1.4rem;
  font-weight: 700;
}

/* Common Mistakes Section */
.mistake-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  margin-bottom: 1.25rem;
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}

.mistake-wrong {
  padding: 0.9rem 1.35rem;
  background: var(--danger-bg);
  border-left: 4px solid var(--danger);
  color: var(--danger-text);
  font-weight: 600;
  font-size: 0.92rem;
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
}

.mistake-correct {
  padding: 0.9rem 1.35rem;
  background: var(--success-bg);
  border-left: 4px solid var(--success);
  color: var(--success-text);
  font-size: 0.9rem;
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
}

/* Practice Sets & Accordion Solutions */
.practice-tier {
  margin: 2rem 0;
}

.tier-title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--text-primary);
}

.practice-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.4rem 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-xs);
  transition: all var(--transition-fast);
}

.practice-card:hover {
  box-shadow: var(--shadow-sm);
  border-color: var(--border-subtle);
}

.practice-question {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.85rem;
  font-size: 0.96rem;
  line-height: 1.6;
}

.solution-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 1rem;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  color: var(--primary-light);
  font-weight: 600;
  font-size: 0.84rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.solution-toggle-btn:hover {
  background: var(--primary-subtle);
  border-color: var(--primary-light);
}

.solution-content {
  display: none;
  margin-top: 1rem;
  padding: 1.15rem 1.35rem;
  background: var(--bg-subtle);
  border-radius: var(--radius-md);
  border-left: 3px solid var(--primary-light);
  font-size: 0.9rem;
  line-height: 1.65;
}

.solution-content.show {
  display: block;
}

/* Interview Questions Box */
.interview-item {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  margin-bottom: 1rem;
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}

.interview-q {
  padding: 1rem 1.4rem;
  font-weight: 700;
  font-size: 0.96rem;
  color: var(--text-primary);
  background: var(--bg-subtle);
  display: flex;
  align-items: center;
  gap: 0.65rem;
  cursor: pointer;
  user-select: none;
}

.interview-a {
  padding: 1.15rem 1.4rem;
  font-size: 0.92rem;
  color: var(--text-secondary);
  line-height: 1.65;
  border-top: 1px solid var(--border-color);
}

/* Interactive Checklist */
.checklist-container {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem 1.75rem;
  margin: 2rem 0;
  box-shadow: var(--shadow-xs);
}

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

.checklist-count {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary-light);
  background: var(--primary-subtle);
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
}

.checklist-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.6rem 0;
  cursor: pointer;
}

.checklist-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin-top: 0.2rem;
  cursor: pointer;
  accent-color: var(--primary-light);
}

.checklist-item label {
  font-size: 0.92rem;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.checklist-item.checked label {
  text-decoration: line-through;
  color: var(--text-muted);
}

/* Universal Quiz Widget */
.quiz-widget {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 2rem;
  margin: 2.25rem 0;
  box-shadow: var(--shadow-sm);
}

.quiz-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.75rem;
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 0.85rem;
}

.quiz-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

.quiz-item {
  margin-bottom: 1.75rem;
  padding-bottom: 1.75rem;
  border-bottom: 1px solid var(--border-color);
}

.quiz-question-text {
  font-weight: 600;
  font-size: 0.98rem;
  color: var(--text-primary);
  margin-bottom: 1rem;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.quiz-option-btn {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.75rem 1.15rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.quiz-option-btn:hover:not(:disabled) {
  background: var(--bg-surface);
  border-color: var(--primary-light);
  box-shadow: var(--shadow-xs);
}

.quiz-option-btn.correct {
  background: var(--success-bg);
  border-color: var(--success);
  color: var(--success-text);
  font-weight: 700;
}

.quiz-option-btn.incorrect {
  background: var(--danger-bg);
  border-color: var(--danger);
  color: var(--danger-text);
}

.quiz-explanation {
  display: none;
  margin-top: 0.85rem;
  padding: 0.85rem 1.15rem;
  background: var(--bg-subtle);
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  border-left: 3px solid var(--primary-light);
  line-height: 1.6;
}

.quiz-explanation.show {
  display: block;
}

.quiz-score-banner {
  display: none;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white;
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  text-align: center;
  margin-top: 1.25rem;
}

/* Quick Revision Box */
.revision-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-left: 5px solid var(--accent);
  border-radius: var(--radius-lg);
  padding: 1.75rem 2rem;
  margin: 2.25rem 0;
  box-shadow: var(--shadow-xs);
}

.revision-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.remember-box {
  background: var(--bg-subtle);
  border: 1px dashed var(--accent);
  border-radius: var(--radius-md);
  padding: 1.15rem 1.35rem;
  margin-top: 1.25rem;
  font-size: 0.92rem;
  color: var(--text-primary);
}

/* Live Global Search Modal */
.search-modal-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 2000;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
}

.search-modal-backdrop.show {
  display: flex;
}

.search-modal {
  width: 90%;
  max-width: 640px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 80vh;
  animation: searchSlideIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes searchSlideIn {
  from { opacity: 0; transform: translateY(-16px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.search-modal-header {
  display: flex;
  align-items: center;
  padding: 1.15rem 1.4rem;
  border-bottom: 1px solid var(--border-color);
  gap: 0.85rem;
  background: var(--bg-surface);
}

.search-input {
  flex: 1;
  background: none;
  border: none;
  font-size: 1.05rem;
  font-family: inherit;
  color: var(--text-primary);
  outline: none;
}

.search-results-list {
  overflow-y: auto;
  padding: 0.85rem;
  max-height: 55vh;
}

.search-result-item {
  display: block;
  padding: 0.85rem 1.15rem;
  border-radius: var(--radius-md);
  margin-bottom: 0.35rem;
  color: var(--text-primary);
  text-decoration: none;
  transition: all var(--transition-fast);
}

.search-result-item:hover,
.search-result-item.focused {
  background: var(--primary-subtle);
  outline: none;
}

.search-result-title {
  font-weight: 600;
  font-size: 0.96rem;
  margin-bottom: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.search-result-snippet {
  font-size: 0.84rem;
  color: var(--text-muted);
}

.search-modal-footer {
  padding: 0.75rem 1.4rem;
  background: var(--bg-subtle);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Authentication & Navigation Badge Styles */
.nav-user-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  position: relative;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.85rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
  box-shadow: var(--shadow-xs);
}

.user-pill .user-name {
  font-family: var(--font-mono);
}

.user-dropdown {
  position: relative;
}

.user-menu-popover {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 260px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  z-index: 1500;
  padding: 0.6rem 0;
  animation: searchSlideIn 0.15s ease-out;
}

.user-menu-popover.show {
  display: block;
}

.user-menu-header {
  padding: 0.75rem 1.25rem;
}

.user-menu-divider {
  height: 1px;
  background: var(--border-color);
  margin: 0.5rem 0;
}

.user-menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.65rem 1.25rem;
  background: none;
  border: none;
  font-size: 0.88rem;
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.user-menu-item:hover {
  background: var(--bg-subtle);
}

/* Document Protected Access Barrier Modal */
.access-lock-backdrop {
  position: fixed;
  top: var(--header-height);
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.access-lock-card {
  max-width: 540px;
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 2.75rem 2.25rem;
  text-align: center;
  box-shadow: var(--shadow-xl);
  animation: searchSlideIn 0.25s ease-out;
}

.access-lock-icon {
  font-size: 3.5rem;
  margin-bottom: 0.85rem;
}

.access-lock-info-box {
  background: var(--bg-subtle);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.15rem 1.4rem;
  margin: 1.5rem 0;
  text-align: center;
}
