/**
 * apple-components-library.css
 * Universal Apple.com-grade Component Library for AUTOGRADING AI.
 * Covers: Segmented Tab Bars, Data Tables, Cards, Form Controls,
 * iOS Switches, Status Badges, Progress Bars, Dropzones, and Callouts.
 * Enforces SOLID + SoC + File Length Ceiling (<= 800 lines).
 */

/* ==========================================================================
   1. UNIVERSAL APPLE SEGMENTED TABS & SWITCHERS
   ========================================================================== */
.studio-mode-pills,
.variant-tab-group {
  display: inline-flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.05);
  border: 1px solid var(--apple-border);
  border-radius: 980px;
  padding: 3px;
  gap: 3px;
  transition: var(--apple-transition-fast);
}

.rubric-mode-tabs, .ocr-input-modes-bar, .apple-segmented-tabs, .nav-tabs,
.sub-modal-tab-nav, .admin-tab-nav, .cycle-switcher-wrapper,
.math-kb-tabs-bar, .math-kb-mode-switcher, .math-visual-tabs-bar,
.math-visual-mode-tabs, .sg-rubric-view-tabs, .sg-page-tabs-bar,
.presentation-theme-selector, .bento-view-switcher, .bento-segmented-group,
.segmented-button-group,
.classroom-tabs-bar {
  display: inline-flex !important;
  align-items: center !important;
  background: rgba(0, 0, 0, 0.05) !important;
  border: 1px solid var(--apple-border) !important;
  border-radius: 980px !important;
  padding: 3px !important;
  gap: 3px !important;
  transition: var(--apple-transition-fast) !important;
}

/* Mobile-First 3-Tab Segmented Bar Grid */
.mobile-sg-tab-bar {
  display: grid !important;
  grid-template-columns: 1fr 1fr 1fr !important;
  width: 100% !important;
  box-sizing: border-box !important;
  background: rgba(0, 0, 0, 0.05) !important;
  border: 1px solid var(--apple-border) !important;
  border-radius: 980px !important;
  padding: 3px !important;
  gap: 3px !important;
}

[data-theme="dark"] .studio-mode-pills, [data-theme="dark"] .variant-tab-group,
[data-theme="dark"] .mobile-sg-tab-bar, [data-theme="dark"] .rubric-mode-tabs,
[data-theme="dark"] .ocr-input-modes-bar, [data-theme="dark"] .apple-segmented-tabs,
[data-theme="dark"] .nav-tabs, [data-theme="dark"] .sub-modal-tab-nav,
[data-theme="dark"] .admin-tab-nav, [data-theme="dark"] .cycle-switcher-wrapper,
[data-theme="dark"] .math-kb-tabs-bar, [data-theme="dark"] .math-kb-mode-switcher,
[data-theme="dark"] .math-visual-tabs-bar, [data-theme="dark"] .math-visual-mode-tabs,
[data-theme="dark"] .sg-rubric-view-tabs, [data-theme="dark"] .sg-page-tabs-bar,
[data-theme="dark"] .presentation-theme-selector, [data-theme="dark"] .bento-view-switcher,
[data-theme="dark"] .bento-segmented-group, [data-theme="dark"] .classroom-tabs-bar {
  background: rgba(255, 255, 255, 0.08) !important;
  border-color: var(--apple-border) !important;
}

/* Tab Action Buttons */
.btn-mode-toggle, .v-tab, .mobile-sg-tab-btn, .rubric-tab-btn,
.apple-tab-item, .sub-tab-btn, .admin-tab-btn, .cycle-switch-btn,
.math-kb-tab-btn, .math-kb-mode-btn, .sg-tab-btn, .sg-page-tab-btn,
.theme-btn, .btn-bento-view, .btn-hub-view, .bento-filter-pill,
.hub-filter-pill, .segmented-btn {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 0.4rem !important;
  border-radius: 980px !important;
  padding: 0.45rem 1rem !important;
  font-size: 0.82rem !important;
  font-weight: 500 !important;
  letter-spacing: -0.01em !important;
  color: var(--apple-text-secondary) !important;
  background: transparent !important;
  border: none !important;
  cursor: pointer !important;
  transition: var(--apple-transition-fast) !important;
  white-space: nowrap !important;
  user-select: none !important;
}

.btn-mode-toggle:hover:not(.active), .v-tab:hover:not(.active),
.mobile-sg-tab-btn:hover:not(.active), .rubric-tab-btn:hover:not(.active),
.sub-tab-btn:hover:not(.active), .admin-tab-btn:hover:not(.active),
.cycle-switch-btn:hover:not(.active), .math-kb-tab-btn:hover:not(.active),
.math-kb-mode-btn:hover:not(.active), .sg-tab-btn:hover:not(.active),
.sg-page-tab-btn:hover:not(.active), .theme-btn:hover:not(.active),
.btn-bento-view:hover:not(.active), .btn-hub-view:hover:not(.active),
.bento-filter-pill:hover:not(.active), .hub-filter-pill:hover:not(.active),
.segmented-btn:hover:not(.active) {
  color: var(--apple-text-primary) !important;
  background: rgba(0, 0, 0, 0.04) !important;
}

[data-theme="dark"] .btn-mode-toggle:hover:not(.active), [data-theme="dark"] .v-tab:hover:not(.active),
[data-theme="dark"] .mobile-sg-tab-btn:hover:not(.active), [data-theme="dark"] .rubric-tab-btn:hover:not(.active),
[data-theme="dark"] .sub-tab-btn:hover:not(.active), [data-theme="dark"] .admin-tab-btn:hover:not(.active),
[data-theme="dark"] .cycle-switch-btn:hover:not(.active), [data-theme="dark"] .math-kb-tab-btn:hover:not(.active),
[data-theme="dark"] .math-kb-mode-btn:hover:not(.active), [data-theme="dark"] .sg-tab-btn:hover:not(.active),
[data-theme="dark"] .sg-page-tab-btn:hover:not(.active), [data-theme="dark"] .theme-btn:hover:not(.active),
[data-theme="dark"] .btn-bento-view:hover:not(.active), [data-theme="dark"] .btn-hub-view:hover:not(.active),
[data-theme="dark"] .bento-filter-pill:hover:not(.active), [data-theme="dark"] .hub-filter-pill:hover:not(.active),
[data-theme="dark"] .segmented-btn:hover:not(.active) {
  background: rgba(255, 255, 255, 0.06) !important;
}

/* Active Tab State (Apple Floating Pill) */
.btn-mode-toggle.active, .v-tab.active, .mobile-sg-tab-btn.active,
.rubric-tab-btn.active, .apple-tab-item.active, .sub-tab-btn.active,
.admin-tab-btn.active, .cycle-switch-btn.active, .math-kb-tab-btn.active,
.math-kb-mode-btn.active, .sg-tab-btn.active, .sg-page-tab-btn.active,
.theme-btn.active, .btn-bento-view.active, .btn-hub-view.active,
.segmented-btn.active {
  background: #ffffff !important;
  color: var(--apple-text-primary) !important;
  font-weight: 600 !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08), 0 0 1px rgba(0, 0, 0, 0.1) !important;
  transform: scale(1.01) !important;
}

.bento-filter-pill.active,
.hub-filter-pill.active {
  background: #ecfeff !important;
  border: 1px solid rgba(0, 197, 223, 0.45) !important;
  color: #082850 !important;
  font-weight: 750 !important;
  box-shadow: 0 2px 8px rgba(0, 197, 223, 0.18) !important;
}

[data-theme="dark"] .btn-mode-toggle.active, [data-theme="dark"] .v-tab.active,
[data-theme="dark"] .mobile-sg-tab-btn.active, [data-theme="dark"] .rubric-tab-btn.active,
[data-theme="dark"] .apple-tab-item.active, [data-theme="dark"] .sub-tab-btn.active,
[data-theme="dark"] .admin-tab-btn.active, [data-theme="dark"] .cycle-switch-btn.active,
[data-theme="dark"] .math-kb-tab-btn.active, [data-theme="dark"] .math-kb-mode-btn.active,
[data-theme="dark"] .sg-tab-btn.active, [data-theme="dark"] .sg-page-tab-btn.active,
[data-theme="dark"] .theme-btn.active, [data-theme="dark"] .btn-bento-view.active,
[data-theme="dark"] .btn-hub-view.active, [data-theme="dark"] .bento-filter-pill.active,
[data-theme="dark"] .hub-filter-pill.active {
  background: #3a3a3c !important;
  color: #ffffff !important;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35) !important;
}

/* ==========================================================================
   2. UNIVERSAL APPLE DATA TABLES (7-COLUMN & ROSTER)
   ========================================================================== */
.table-responsive,
.data-table-wrapper,
.school-table-container,
.ocr-rubric-table-wrapper {
  background: var(--apple-surface) !important;
  border: 1px solid var(--apple-border) !important;
  border-radius: 18px !important;
  box-shadow: var(--apple-shadow-subtle) !important;
  overflow-x: auto !important;
  overflow-y: hidden !important;
  position: relative !important;
  -webkit-overflow-scrolling: touch !important;
  scrollbar-width: thin !important;
  margin-bottom: 1.5rem !important;
}

.table-responsive::-webkit-scrollbar { height: 6px; }
.table-responsive::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.02); border-radius: 999px; }
.table-responsive::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, 0.2); border-radius: 999px; }

.submissions-table, .data-table, .scores-table, .ocr-rubric-table {
  width: 100% !important;
  border-collapse: separate !important;
  border-spacing: 0 !important;
  font-family: var(--apple-font) !important;
}

/* Table Header */
.submissions-table thead, .data-table thead, .scores-table thead, .ocr-rubric-table thead {
  background: rgba(0, 0, 0, 0.02) !important;
  border-bottom: 1px solid var(--apple-divider) !important;
}

[data-theme="dark"] .submissions-table thead,
[data-theme="dark"] .data-table thead,
[data-theme="dark"] .scores-table thead,
[data-theme="dark"] .ocr-rubric-table thead {
  background: rgba(255, 255, 255, 0.04) !important;
}

.submissions-table th, .submissions-table td { padding: 0.55rem 0.45rem !important; }
.submissions-table th.col-stt, .submissions-table td.col-stt { padding-left: 0.55rem !important; width: 44px !important; min-width: 40px !important; text-align: center !important; }
.submissions-table th.col-variant, .submissions-table td.col-variant { width: 68px !important; min-width: 60px !important; text-align: center !important; }
.submissions-table th.col-pages, .submissions-table td.col-pages { width: 88px !important; min-width: 80px !important; text-align: center !important; }
.submissions-table th.col-status, .submissions-table td.col-status { width: 92px !important; min-width: 85px !important; text-align: center !important; }
.submissions-table th.col-score, .submissions-table td.col-score { width: 96px !important; min-width: 90px !important; text-align: center !important; }
.submissions-table th.col-actions, .submissions-table td.col-actions { padding-right: 0.55rem !important; }


.data-table th,
.scores-table th,
.ocr-rubric-table th,
.sortable-th {
  padding: 0.85rem 1.15rem !important;
  font-size: 0.74rem !important;
  font-weight: 600 !important;
  letter-spacing: 0.04em !important;
  text-transform: uppercase !important;
  color: var(--apple-text-tertiary) !important;
  border-bottom: 1px solid var(--apple-divider) !important;
  white-space: nowrap !important;
}

.sortable-th:hover {
  color: var(--apple-text-primary) !important;
  background: rgba(0, 0, 0, 0.02) !important;
  cursor: pointer !important;
}

/* Table Body Rows */
.submissions-table tbody tr,
.data-table tbody tr,
.scores-table tbody tr,
.ocr-rubric-table tbody tr {
  transition: var(--apple-transition-fast) !important;
  border-bottom: 1px solid var(--apple-divider) !important;
}

.submissions-table tbody tr:hover,
.data-table tbody tr:hover,
.scores-table tbody tr:hover,
.ocr-rubric-table tbody tr:hover {
  background: var(--apple-blue-tint) !important;
}

.data-table td,
.scores-table td,
.ocr-rubric-table td {
  padding: 0.95rem 1.15rem !important;
  font-size: 0.88rem !important;
  color: var(--apple-text-primary) !important;
  vertical-align: middle !important;
  border-bottom: 1px solid var(--apple-divider) !important;
}

/* ==========================================================================
   3. UNIVERSAL APPLE CARDS, TILES & ACCORDIONS
   ========================================================================== */
.studio-card,
.parent-kpi-card,
.parent-card-section,
.ocr-stage-card,
.portal-card,
.bento-card,
.bento-tile,
.math-visual-viewport-wrapper,
.teacher-presentation-workspace,
.math-kb-container,
.auth-modal-content,
.math-solution-modal-content,
.rubric-studio-modal-content,
.score-breakdown-modal-content {
  background: var(--apple-surface) !important;
  border: 1px solid var(--apple-border) !important;
  border-radius: 18px !important;
  box-shadow: var(--apple-shadow-card) !important;
  padding: 1.35rem 1.5rem !important;
  transition: var(--apple-transition-medium) !important;
}

.studio-card:hover,
.bento-card:hover,
.parent-kpi-card:hover {
  border-color: var(--apple-border-hover) !important;
  box-shadow: var(--apple-shadow-hover) !important;
  transform: translateY(-1.5px) !important;
}

/* Parent KPI Numbers */
.parent-kpi-value {
  font-size: 2.2rem !important;
  font-weight: 800 !important;
  letter-spacing: -0.03em !important;
  color: var(--apple-blue) !important;
  line-height: 1.1 !important;
}

.parent-kpi-label {
  font-size: 0.78rem !important;
  font-weight: 600 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.04em !important;
  color: var(--apple-text-tertiary) !important;
}

/* ==========================================================================
   4. APPLE STATUS BADGES & CAPSULE PILLS
   ========================================================================== */
.badge-success,
.badge-submitted,
.status-pill-done {
  background: var(--apple-green-tint) !important;
  color: #15803d !important;
  border: 1px solid rgba(52, 199, 89, 0.3) !important;
  border-radius: 980px !important;
  font-weight: 600 !important;
  padding: 3px 10px !important;
}

[data-theme="dark"] .badge-success,
[data-theme="dark"] .badge-submitted,
[data-theme="dark"] .status-pill-done {
  color: #4ade80 !important;
  border-color: rgba(74, 222, 128, 0.35) !important;
}

.badge-warning,
.status-pill-pending {
  background: var(--apple-orange-tint) !important;
  color: #b45309 !important;
  border: 1px solid rgba(255, 149, 0, 0.3) !important;
  border-radius: 980px !important;
  font-weight: 600 !important;
  padding: 3px 10px !important;
}

[data-theme="dark"] .badge-warning,
[data-theme="dark"] .status-pill-pending {
  color: #fbbf24 !important;
  border-color: rgba(251, 191, 36, 0.35) !important;
}

.badge-danger,
.badge-defect {
  background: var(--apple-red-tint) !important;
  color: #dc2626 !important;
  border: 1px solid rgba(255, 59, 48, 0.3) !important;
  border-radius: 980px !important;
  font-weight: 600 !important;
  padding: 3px 10px !important;
}

[data-theme="dark"] .badge-danger,
[data-theme="dark"] .badge-defect {
  color: #f87171 !important;
  border-color: rgba(248, 113, 113, 0.35) !important;
}

/* ==========================================================================
   5. APPLE PROGRESS BARS & SHIMMER TRACKS
   ========================================================================== */
.progress-bar-track,
.stat-progress-bar,
.grading-progress-track {
  height: 6px !important;
  background: rgba(0, 0, 0, 0.06) !important;
  border-radius: 980px !important;
  overflow: hidden !important;
  position: relative !important;
}

[data-theme="dark"] .progress-bar-track,
[data-theme="dark"] .stat-progress-bar,
[data-theme="dark"] .grading-progress-track {
  background: rgba(255, 255, 255, 0.1) !important;
}

.progress-bar-fill {
  height: 100% !important;
  background: linear-gradient(90deg, var(--apple-blue) 0%, #3ca2ff 100%) !important;
  border-radius: 980px !important;
  transition: width 0.4s var(--apple-ease) !important;
}

/* ==========================================================================
   6. APPLE CALLOUTS & AUDIT ALERT BANNERS
   ========================================================================== */
.archived-year-alert,
.exam-audit-hero-banner,
.grading-progress-banner {
  border-radius: 16px !important;
  padding: 1rem 1.35rem !important;
  box-shadow: var(--apple-shadow-subtle) !important;
  transition: var(--apple-transition-fast) !important;
  border: 1px solid var(--apple-border) !important;
}

.exam-audit-hero-banner {
  background: linear-gradient(135deg, rgba(255, 59, 48, 0.06) 0%, rgba(255, 255, 255, 0.95) 100%) !important;
  border-color: rgba(255, 59, 48, 0.35) !important;
}

[data-theme="dark"] .exam-audit-hero-banner {
  background: rgba(44, 20, 20, 0.85) !important;
  border-color: rgba(255, 59, 48, 0.45) !important;
}

/* ==========================================================================
   7. UNIVERSAL APPLE MODAL BACKDROP & SQUIRCLE OVERRIDES (ALL MODALS)
   ========================================================================== */
.modal-backdrop,
.modal-backdrop.active,
.modal.active,
.modal-overlay {
  backdrop-filter: blur(28px) saturate(190%) !important;
  -webkit-backdrop-filter: blur(28px) saturate(190%) !important;
  background: rgba(0, 0, 0, 0.45) !important;
}

.modal-content,
.modal-box,
.modal-dialog {
  background: rgba(255, 255, 255, 0.96) !important;
  backdrop-filter: blur(40px) saturate(200%) !important;
  -webkit-backdrop-filter: blur(40px) saturate(200%) !important;
  border: 1px solid rgba(255, 255, 255, 0.8) !important;
  border-radius: 22px !important;
  box-shadow: 
    0 24px 60px -15px rgba(0, 0, 0, 0.22),
    0 0 0 1px rgba(0, 0, 0, 0.05),
    inset 0 1px 1px 0 rgba(255, 255, 255, 0.9) !important;
  color: var(--apple-text-primary) !important;
  font-family: var(--apple-font) !important;
}

[data-theme="dark"] .modal-content,
[data-theme="dark"] .modal-box,
[data-theme="dark"] .modal-dialog {
  background: rgba(28, 28, 30, 0.94) !important;
  border-color: rgba(255, 255, 255, 0.12) !important;
  color: #f5f5f7 !important;
  box-shadow: 
    0 30px 70px -15px rgba(0, 0, 0, 0.65),
    0 0 0 1px rgba(255, 255, 255, 0.08),
    inset 0 1px 1px 0 rgba(255, 255, 255, 0.15) !important;
}

/* ==========================================================================
   8. UNIVERSAL APPLE FORM CONTROLS, SELECTS & TOGGLES
   ========================================================================== */
select,
.form-select,
.time-scope-dropdown,
.time-scope-select-wrap select,
#select-math-visual-mode {
  appearance: none !important;
  -webkit-appearance: none !important;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2386868b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 0.85rem center !important;
  background-size: 12px !important;
  padding-right: 2.2rem !important;
  border-radius: 980px !important;
  border: 1px solid var(--apple-border) !important;
  background-color: var(--apple-input-bg) !important;
  color: var(--apple-text-primary) !important;
  font-family: var(--apple-font) !important;
  font-size: 0.84rem !important;
  font-weight: 500 !important;
  cursor: pointer !important;
  transition: var(--apple-transition-fast) !important;
}

select:focus,
.form-select:focus,
.time-scope-dropdown:focus {
  background-color: #ffffff !important;
  border-color: var(--apple-blue) !important;
  box-shadow: 0 0 0 3px var(--apple-blue-ring) !important;
  outline: none !important;
}

[data-theme="dark"] select,
[data-theme="dark"] .form-select,
[data-theme="dark"] .time-scope-dropdown,
[data-theme="dark"] #select-math-visual-mode {
  background-color: rgba(255, 255, 255, 0.08) !important;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a1a1a6' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") !important;
  color: #f5f5f7 !important;
}

[data-theme="dark"] select:focus,
[data-theme="dark"] .form-select:focus,
[data-theme="dark"] .time-scope-dropdown:focus {
  background-color: #2c2c2e !important;
}

/* Universal Input & Textarea */
input[type="text"]:not(.input-gate),
input[type="password"]:not(.input-gate),
input[type="email"]:not(.input-gate),
input[type="number"],
input[type="search"],
input[type="date"],
textarea,
.form-control,
.ocr-latex-textarea {
  background: var(--apple-input-bg) !important;
  border: 1px solid var(--apple-border) !important;
  border-radius: 12px !important;
  color: var(--apple-text-primary) !important;
  font-family: var(--apple-font) !important;
  padding: 0.62rem 0.9rem !important;
  font-size: 0.86rem !important;
  transition: var(--apple-transition-fast) !important;
  outline: none !important;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
input[type="number"]:focus,
input[type="search"]:focus,
input[type="date"]:focus,
textarea:focus,
.form-control:focus,
.ocr-latex-textarea:focus {
  background: #ffffff !important;
  border-color: var(--apple-blue) !important;
  box-shadow: 0 0 0 3px var(--apple-blue-ring) !important;
}

[data-theme="dark"] input[type="text"]:focus,
[data-theme="dark"] input[type="password"]:focus,
[data-theme="dark"] input[type="email"]:focus,
[data-theme="dark"] input[type="number"]:focus,
[data-theme="dark"] input[type="search"]:focus,
[data-theme="dark"] input[type="date"]:focus,
[data-theme="dark"] textarea:focus,
[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .ocr-latex-textarea:focus {
  background: #2c2c2e !important;
}

/* Range Slider */
input[type="range"] {
  -webkit-appearance: none !important;
  appearance: none !important;
  width: 100% !important;
  height: 6px !important;
  background: rgba(0, 0, 0, 0.08) !important;
  border-radius: 980px !important;
  outline: none !important;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none !important;
  appearance: none !important;
  width: 20px !important;
  height: 20px !important;
  border-radius: 50% !important;
  background: #ffffff !important;
  border: 0.5px solid rgba(0, 0, 0, 0.1) !important;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25) !important;
  cursor: pointer !important;
  transition: transform 0.15s ease !important;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15) !important;
}

/* iOS Toggle Switch */
.ios-switch,
.apple-toggle {
  position: relative !important;
  display: inline-block !important;
  width: 44px !important;
  height: 26px !important;
}

.ios-switch input,
.apple-toggle input {
  opacity: 0 !important;
  width: 0 !important;
  height: 0 !important;
}

.ios-slider,
.apple-toggle-slider {
  position: absolute !important;
  cursor: pointer !important;
  inset: 0 !important;
  background-color: rgba(120, 120, 128, 0.2) !important;
  transition: 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
  border-radius: 980px !important;
}

.ios-slider:before,
.apple-toggle-slider:before {
  position: absolute !important;
  content: "" !important;
  height: 20px !important;
  width: 20px !important;
  left: 3px !important;
  bottom: 3px !important;
  background-color: #ffffff !important;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.22) !important;
  transition: 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
  border-radius: 50% !important;
}

input:checked + .ios-slider,
input:checked + .apple-toggle-slider {
  background-color: var(--apple-green) !important;
}

input:checked + .ios-slider:before,
input:checked + .apple-toggle-slider:before {
  transform: translateX(18px) !important;
}

/* ==========================================================================
   9. UNIVERSAL APPLE CONTEXT MENUS, POPOVERS & FLOATING TOOLBARS
   ========================================================================== */
.compact-options-popover,
.dropdown-menu,
.options-popover,
.smart-context-dropdown,
.apple-dropdown-menu {
  background: rgba(255, 255, 255, 0.95) !important;
  backdrop-filter: blur(28px) saturate(190%) !important;
  -webkit-backdrop-filter: blur(28px) saturate(190%) !important;
  border: 1px solid var(--apple-border) !important;
  border-radius: 14px !important;
  box-shadow: var(--apple-shadow-dropdown) !important;
  padding: 6px !important;
  z-index: 1000 !important;
}

[data-theme="dark"] .compact-options-popover,
[data-theme="dark"] .dropdown-menu,
[data-theme="dark"] .options-popover,
[data-theme="dark"] .smart-context-dropdown,
[data-theme="dark"] .apple-dropdown-menu {
  background: rgba(44, 44, 46, 0.94) !important;
  border-color: rgba(255, 255, 255, 0.12) !important;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.6) !important;
}

.btn-popover-item,
.dropdown-item-btn,
.dropdown-item {
  display: flex !important;
  align-items: center !important;
  width: 100% !important;
  padding: 0.55rem 0.85rem !important;
  border-radius: 8px !important;
  font-size: 0.83rem !important;
  font-weight: 500 !important;
  color: var(--apple-text-primary) !important;
  background: transparent !important;
  border: none !important;
  cursor: pointer !important;
  transition: var(--apple-transition-fast) !important;
  text-align: left !important;
}

.btn-popover-item:hover,
.dropdown-item-btn:hover,
.apple-dropdown-menu .dropdown-item:hover {
  background: var(--apple-blue) !important;
  color: #ffffff !important;
}

.dropdown-item-danger:hover,
.danger-item:hover {
  background: var(--apple-red) !important;
  color: #ffffff !important;
}

/* ==========================================================================
   10. UNIVERSAL APPLE EMPTY STATES, MICRO SPINNERS & SKELETON SHIMMER
   ========================================================================== */
.empty-state,
.zero-state-card {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 3rem 1.5rem !important;
  text-align: center !important;
  background: var(--apple-surface) !important;
  border: 1px dashed var(--apple-border) !important;
  border-radius: 20px !important;
}

.empty-state-icon { font-size: 2.5rem !important; color: var(--apple-text-tertiary) !important; margin-bottom: 0.75rem !important; }
.empty-state-title { font-size: 1.15rem !important; font-weight: 700 !important; color: var(--apple-text-primary) !important; margin-bottom: 0.35rem !important; }
.empty-state-desc { font-size: 0.85rem !important; color: var(--apple-text-secondary) !important; max-width: 420px !important; margin-bottom: 1.25rem !important; }

.spinner-micro {
  width: 14px !important;
  height: 14px !important;
  border: 2px solid rgba(0, 113, 227, 0.25) !important;
  border-top-color: currentColor !important;
  border-radius: 50% !important;
  animation: appleSpin 0.7s linear infinite !important;
  display: inline-block;
  vertical-align: middle !important;
  flex-shrink: 0 !important;
}
.btn-primary .spinner-micro,
.btn-executive .spinner-micro,
.btn-danger .spinner-micro {
  border-color: rgba(255, 255, 255, 0.35) !important;
  border-top-color: #ffffff !important;
}
.spinner-micro[style*="display: none"],
.spinner-micro[style*="display:none"],
.spinner-micro.hidden,
.spinner-micro[hidden] {
  display: none !important;
  animation: none !important;
}

@keyframes appleSpin {
  to { transform: rotate(360deg); }
}

/* ==========================================================================
   11. WORKSHEET FORMAT SELECTOR & RESPONSIVE TOUCH CARDS
   ========================================================================== */
.worksheet-format-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

.worksheet-format-option {
  position: relative;
  cursor: pointer;
  border: 1.5px solid var(--border-color, #e2e8f0);
  border-radius: 12px;
  padding: 0.75rem 0.95rem;
  background: var(--surface-card, #ffffff);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
}

.worksheet-format-option:hover {
  border-color: var(--primary-light, #93c5fd);
  background: var(--surface-hover, #f8fafc);
  transform: translateY(-1px);
}

.worksheet-format-option.active {
  border-color: var(--primary, #2563eb) !important;
  background: rgba(37, 99, 235, 0.04) !important;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

@media (max-width: 580px) {
  .worksheet-format-selector {
    grid-template-columns: 1fr !important;
    gap: 0.5rem !important;
  }
  .worksheet-format-option {
    padding: 0.7rem 0.85rem !important;
  }
}
