/* ============================================
   Responsive Design - All Screen Sizes
   ============================================ */

/* ============================================
   CSS Custom Properties for Responsive Design
   ============================================ */
:root {
  /* Fluid spacing scale */
  --space-responsive-xs: clamp(0.125rem, 0.5vw, 0.25rem);
  --space-responsive-sm: clamp(0.25rem, 1vw, 0.5rem);
  --space-responsive-md: clamp(0.5rem, 2vw, 1rem);
  --space-responsive-lg: clamp(0.75rem, 3vw, 1.5rem);
  --space-responsive-xl: clamp(1rem, 4vw, 2rem);
  
  /* Fluid typography scale */
  --font-size-fluid-xs: clamp(0.65rem, 0.6rem + 0.25vw, 0.75rem);
  --font-size-fluid-sm: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --font-size-fluid-base: clamp(0.875rem, 0.8rem + 0.375vw, 1rem);
  --font-size-fluid-lg: clamp(1rem, 0.9rem + 0.5vw, 1.125rem);
  --font-size-fluid-xl: clamp(1.125rem, 1rem + 0.625vw, 1.25rem);
  --font-size-fluid-2xl: clamp(1.25rem, 1.1rem + 0.75vw, 1.5rem);
  --font-size-fluid-3xl: clamp(1.5rem, 1.25rem + 1.25vw, 2rem);
  --font-size-fluid-4xl: clamp(1.75rem, 1.5rem + 1.5vw, 2.5rem);
  
  /* Container widths */
  --container-xs: 320px;
  --container-sm: 420px;
  --container-md: 600px;
  --container-lg: 700px;
  --container-xl: 800px;
}

/* ============================================
   Global Responsive Foundations
   ============================================ */

/* Prevent horizontal overflow globally */
html, body, #app {
  max-width: 100vw;
  overflow-x: hidden;
}

/* Responsive images and media */
img, video, iframe, embed, object {
  max-width: 100%;
  height: auto;
}

/* Responsive tables */
table {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  display: block;
}

/* Word breaking for long text */
h1, h2, h3, h4, h5, h6, p, li, td, th, label, span, a {
  overflow-wrap: break-word;
  word-wrap: break-word;
  hyphens: auto;
}

/* ============================================
   Breakpoints:
   - Mobile: 320px - 480px (small phones)
   - Large Mobile: 481px - 640px (large phones)
   - Small Tablet: 641px - 768px (portrait tablets)
   - Tablet: 769px - 1024px (landscape tablets)
   - Desktop: 1025px - 1280px
   - Large Desktop: 1281px+
   ============================================ */

/* ============================================
   Extra Small Mobile (320px - 360px)
   ============================================ */
@media (max-width: 360px) {
  :root {
    --font-size-4xl: 1.75rem;
    --font-size-3xl: 1.5rem;
    --font-size-2xl: 1.25rem;
    --font-size-xl: 1rem;
    --font-size-lg: 0.9375rem;
    --space-xl: 1.25rem;
    --space-2xl: 1.75rem;
    --space-3xl: 2rem;
  }

  #app {
    max-width: 100%;
    border-radius: 0;
    box-shadow: none;
  }

  body {
    padding: 0;
  }

  #app-header {
    padding: var(--space-xs) var(--space-sm);
    min-height: 52px;
  }

  .header-title {
    font-size: var(--font-size-base);
  }

  .header-btn {
    width: 36px;
    height: 36px;
  }

  #main-content {
    padding: var(--space-sm);
    padding-bottom: calc(var(--space-md) + 70px);
  }

  /* Buttons */
  .btn {
    padding: 10px 16px;
    font-size: var(--font-size-sm);
    min-height: 40px;
  }

  .btn-lg {
    padding: 12px 20px;
    font-size: var(--font-size-base);
  }

  /* Cards */
  .card {
    padding: var(--space-sm);
    border-radius: var(--radius-lg);
  }

  /* Forms */
  .form-input,
  .form-select {
    padding: 10px 12px;
    font-size: var(--font-size-sm);
  }

  /* Welcome Screen */
  .welcome-screen {
    padding: var(--space-md);
    padding-top: var(--space-lg);
  }

  .logo-circle {
    width: 64px;
    height: 64px;
  }

  .brand-title {
    font-size: var(--font-size-2xl);
  }

  .feature-item {
    padding: var(--space-xs) var(--space-sm);
    gap: var(--space-sm);
  }

  .feature-icon {
    width: 36px;
    height: 36px;
  }

  /* Bottom Navigation */
  #bottom-nav {
    padding: var(--space-xs) 0;
  }

  .nav-item {
    padding: var(--space-xs);
    font-size: var(--font-size-sm);
    min-height: 44px;
  }

  .nav-item svg {
    width: 20px;
    height: 20px;
  }

  /* Multi-select */
  .multi-select-option {
    padding: 6px 10px;
    font-size: 11px;
    gap: 4px;
  }

  /* OTP Inputs */
  .otp-inputs {
    gap: var(--space-xs);
  }

  .otp-input {
    width: 40px;
    height: 40px;
    font-size: var(--font-size-lg);
  }

  /* Profile select — smaller circles on narrow phones */
  .profiles-row,
  .profile-grid {
    gap: 24px;
  }

  .profile-select-screen {
    --profile-circle-size: 120px;
  }

  .profile-card,
  .add-profile-card {
    min-width: 120px;
  }

  .profile-select-screen .profile-avatar.avatar-icon svg {
    max-width: 92px;
    max-height: 92px;
  }

  /* S3 Configure - Difficulty/Format Pills */
  .s3-configure .difficulty-options,
  .s3-configure .format-options {
    gap: 6px;
    flex-wrap: wrap;
  }

  .s3-configure .difficulty-pill,
  .s3-configure .format-pill {
    padding: 10px 6px;
    gap: 4px;
    min-width: 0;
    flex: 1 1 calc(33.33% - 4px);
  }

  .s3-configure .format-pill .pill-description {
    font-size: 8px;
    display: none;
  }

  /* History items */
  .history-item {
    padding: var(--space-sm);
    gap: var(--space-sm);
  }

  .history-item-icon {
    width: 32px;
    height: 32px;
  }

  .history-item-score {
    font-size: var(--font-size-base);
    padding: var(--space-xs);
  }

  /* Modal */
  .modal-content {
    width: 95%;
    max-width: 95%;
    padding: var(--space-md);
    margin: var(--space-sm);
  }

  /* Stats grid */
  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-xs);
  }

  .stat-card {
    padding: var(--space-xs);
  }

  .stat-icon {
    width: 32px;
    height: 32px;
  }

  .stat-value {
    font-size: var(--font-size-base);
  }

  .stat-label {
    font-size: 9px;
  }

  /* Settings */
  .settings-section {
    margin-bottom: var(--space-lg);
  }

  .settings-section .section-title {
    font-size: var(--font-size-base);
    padding: 0;
    margin-bottom: var(--space-sm);
  }

  .setting-item {
    padding: 14px 12px;
    gap: 8px;
    align-items: center;
  }

  .setting-label {
    font-size: var(--font-size-sm);
    line-height: 1.35;
  }

  .setting-desc {
    font-size: var(--font-size-xs);
    line-height: 1.4;
  }

  .setting-item svg {
    width: 18px;
    height: 18px;
    margin-top: 0;
  }

  .consent-badge {
    font-size: 10px;
    padding: 4px 9px;
  }

  .version-info p {
    font-size: var(--font-size-xs);
  }

  .version-info p:first-child {
    font-size: var(--font-size-sm);
  }
}

/* ============================================
   Mobile (320px - 480px)
   ============================================ */
@media (max-width: 480px) {
  :root {
    --font-size-4xl: 2rem;
    --font-size-3xl: 1.75rem;
    --font-size-2xl: 1.375rem;
    --font-size-xl: 1.125rem;
    --space-xl: 1.5rem;
    --space-2xl: 2rem;
    --space-3xl: 2.5rem;
  }

  /* App Container */
  #app {
    max-width: 100%;
    border-radius: 0;
    box-shadow: none;
  }

  body {
    padding: 0;
  }

  /* Header */
  #app-header {
    padding: var(--space-sm) var(--space-md);
    min-height: 56px;
  }

  .header-title {
    font-size: var(--font-size-lg);
  }

  .header-btn {
    width: 40px;
    height: 40px;
    min-width: 44px;
    min-height: 44px;
  }

  /* Main Content */
  #main-content {
    padding: var(--space-md);
    padding-bottom: calc(var(--space-md) + 80px);
  }

  /* Buttons */
  .btn {
    padding: 12px 20px;
    font-size: var(--font-size-sm);
    min-height: 44px;
  }

  .btn-lg {
    padding: 14px 24px;
    font-size: var(--font-size-base);
  }

  .btn-block {
    width: 100%;
    justify-content: center;
  }

  /* Cards */
  .card {
    padding: var(--space-md);
    margin-bottom: var(--space-md);
  }

  /* Forms */
  .form-group {
    margin-bottom: var(--space-md);
  }

  .form-input,
  .form-select {
    padding: 12px 16px;
    font-size: var(--font-size-base);
    min-height: 48px;
  }

  .form-row {
    grid-template-columns: 1fr;
    gap: var(--space-md);
  }

  /* Welcome Screen */
  .welcome-screen {
    padding: var(--space-lg);
    padding-top: var(--space-2xl);
  }

  .logo-circle {
    width: 80px;
    height: 80px;
  }

  .brand-title {
    font-size: var(--font-size-3xl);
  }

  .welcome-features {
    margin-bottom: var(--space-xl);
  }

  .feature-item {
    padding: var(--space-sm) var(--space-md);
  }

  /* Bottom Navigation */
  #bottom-nav {
    padding: var(--space-xs) var(--space-sm);
  }

  .nav-item {
    padding: var(--space-xs);
    font-size: var(--font-size-sm);
    min-height: 48px;
    min-width: 48px;
  }

  .nav-item svg {
    width: 22px;
    height: 22px;
  }

  /* Multi-select */
  .multi-select-container {
    gap: var(--space-xs);
  }

  .multi-select-option {
    padding: 8px 12px;
    font-size: var(--font-size-xs);
  }

  /* Difficulty and Format Pills */
  .s3-configure .difficulty-options,
  .s3-configure .format-options {
    gap: 8px;
  }

  .s3-configure .difficulty-pill,
  .s3-configure .format-pill {
    padding: 12px 8px;
    gap: 6px;
    min-height: 60px;
  }

  .s3-configure .format-pill .pill-description {
    font-size: 9px;
  }

  /* Stepper */
  .stepper {
    gap: var(--space-sm);
  }

  .stepper-btn {
    width: 40px;
    height: 40px;
    min-width: 44px;
    min-height: 44px;
  }

  /* OTP Inputs */
  .otp-inputs {
    gap: var(--space-sm);
  }

  .otp-input {
    width: 44px;
    height: 44px;
    font-size: var(--font-size-lg);
  }

  /* Screen Headers */
  .screen-header h1 {
    font-size: var(--font-size-2xl);
  }

  .screen-header .subtitle {
    font-size: var(--font-size-sm);
  }

  /* Auth Screens */
  .auth-screen {
    padding: var(--space-lg);
  }

  .auth-header h1 {
    font-size: var(--font-size-2xl);
  }

  /* Question Renderer */
  .question-card {
    padding: var(--space-md);
  }

  .question-number {
    font-size: var(--font-size-sm);
    width: 28px;
    height: 28px;
  }

  .question-text {
    font-size: var(--font-size-base);
  }

  /* S4 — digital test: stack header, tighten prompt */
  .s4-digital-taking {
    max-width: 100%;
    padding-left: var(--space-sm);
    padding-right: var(--space-sm);
  }

  .s4-digital-taking .s4-exam-header {
    flex-direction: column;
    align-items: stretch;
  }

  .s4-digital-taking .test-id {
    align-self: flex-start;
  }

  .s4-digital-taking .s4-progress-panel {
    padding: var(--space-sm) var(--space-md);
  }

  .s4-digital-taking #question-text {
    padding: var(--space-md) var(--space-md) var(--space-md) calc(var(--space-md) + 4px);
    font-size: clamp(1.125rem, 4vw, 1.375rem);
  }

  /* S7 — expanded question: stack label above answer on narrow screens */
  .result-answer-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .result-answer-label {
    padding-top: 0;
  }

  /* Progress Bar */
  .progress-bar {
    height: 6px;
  }

  /* Modal */
  .modal-overlay {
    padding: var(--space-sm);
  }

  .modal-content {
    width: 95%;
    max-width: 95%;
    padding: var(--space-lg);
    border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
  }

  /* Dropdown Menu */
  .dropdown-menu {
    width: calc(100% - 32px);
    max-width: 280px;
    right: var(--space-md);
  }

  /* Settings */
  .settings-section {
    margin-bottom: var(--space-xl);
  }

  .settings-section .section-title {
    font-size: var(--font-size-lg);
    padding: 0;
    margin-bottom: var(--space-md);
  }

  .settings-section .section-title svg {
    width: 20px;
    height: 20px;
  }

  .settings-card {
    border-radius: var(--radius-xl);
  }

  .setting-item {
    padding: 16px 14px;
    flex-wrap: nowrap;
    gap: var(--space-sm);
    align-items: center;
  }

  .setting-info {
    flex: 1 1 auto;
    min-width: 0;
    padding-right: var(--space-xs);
  }

  .setting-label {
    font-size: var(--font-size-base);
    line-height: 1.35;
    margin-bottom: 4px;
    word-wrap: break-word;
    overflow-wrap: break-word;
  }

  .setting-desc {
    font-size: var(--font-size-sm);
    line-height: 1.45;
    word-wrap: break-word;
    overflow-wrap: break-word;
    display: block;
    margin-top: 0;
  }

  .setting-item svg {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    margin-top: 0;
  }

  .consent-badge-container {
    flex-shrink: 0;
  }

  .consent-badge {
    font-size: var(--font-size-xs);
    padding: 4px 10px;
    white-space: nowrap;
  }

  .version-info {
    padding: var(--space-lg) var(--space-sm);
    text-align: center;
  }

  .version-info p {
    font-size: var(--font-size-sm);
    line-height: 1.45;
  }

  .version-info p:first-child {
    font-size: var(--font-size-base);
  }

  /* History Items */
  .history-item {
    padding: var(--space-md);
  }

  /* Profile Cards */
  .profiles-row,
  .profile-grid {
    gap: 30px;
  }

  .profile-select-screen {
    --profile-circle-size: 152px;
  }

  .profile-card,
  .add-profile-card {
    min-width: 152px;
  }

  .profile-select-screen .profile-avatar.avatar-icon svg {
    max-width: 116px;
    max-height: 116px;
  }

  /* Question Options */
  .question-options {
    gap: var(--space-sm);
  }

  .option-btn,
  .mcq-option {
    padding: 12px 16px;
    font-size: var(--font-size-sm);
    min-height: 48px;
  }

  /* Progress Indicators */
  .progress-info {
    font-size: var(--font-size-sm);
  }

  /* Action Cards */
  .s0-entry .action-card {
    padding: var(--space-md);
    gap: var(--space-sm);
  }

  .s0-entry .action-card .card-icon {
    width: 44px;
    height: 44px;
  }

  .s0-entry .action-card .card-title {
    font-size: var(--font-size-base);
  }

  .s0-entry .action-card .card-subtitle {
    font-size: var(--font-size-xs);
  }

  /* Type cards (S2) */
  .s2-assessment-type .type-card {
    padding: var(--space-md);
    gap: var(--space-sm);
  }

  .s2-assessment-type .type-icon {
    width: 44px;
    height: 44px;
  }

  .s2-assessment-type .type-title {
    font-size: var(--font-size-lg);
  }

  .s2-assessment-type .type-description {
    font-size: var(--font-size-sm);
  }

  /* Subject chips */
  .subject-chips {
    gap: 6px;
  }

  .subject-chip {
    padding: 6px 12px;
    font-size: 12px;
  }

  /* Upload section */
  .s6-upload .upload-options.horizontal {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .s6-upload .upload-option-btn {
    flex-direction: column;
    justify-content: center;
    gap: 10px;
    padding: 16px 12px;
    min-height: 100px;
  }
  
  .s6-upload .upload-option-btn .option-icon {
    width: 48px;
    height: 48px;
  }
  
  .s6-upload .upload-option-btn .option-label {
    font-size: var(--font-size-sm);
  }

  /* Score display */
  .score-ring-container {
    width: 132px;
    height: 132px;
  }

  .score-inner {
    width: 96px;
    height: 96px;
  }

  .score-value {
    font-size: clamp(1.75rem, 6vw, 2.35rem);
  }

  .score-total-value {
    font-size: clamp(1.05rem, 3.8vw, 1.45rem);
  }

  /* Voice input */
  .voice-input-container {
    bottom: 80px;
    right: var(--space-md);
  }

  .voice-input-btn {
    padding: 8px 14px 8px 10px;
  }

  .voice-btn-inner {
    width: 32px;
    height: 32px;
  }

  .voice-btn-label {
    font-size: 12px;
  }
}

/* ============================================
   Large Mobile / Small Tablet (481px - 768px)
   ============================================ */
@media (min-width: 481px) and (max-width: 768px) {
  body {
    padding: 0;
    align-items: stretch;
    justify-content: flex-start;
  }

  #app {
    max-width: 100%;
    width: 100%;
    border-radius: 0;
    box-shadow: none;
  }

  #main-content {
    padding: var(--space-lg);
    padding-bottom: calc(var(--space-lg) + 80px);
  }

  .welcome-screen {
    padding: var(--space-xl);
  }

  .form-row {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
  }

  .card {
    padding: var(--space-lg);
  }

  .modal-content {
    width: 85%;
    max-width: 500px;
  }

  .grid-2 {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-md);
  }

  .profile-grid {
    gap: 32px;
  }

  .welcome-actions {
    gap: var(--space-md);
  }

  .s2-assessment-type .type-cards {
    gap: var(--space-md);
  }

  .s6-upload .upload-options.horizontal {
    grid-template-columns: repeat(3, 1fr);
  }

  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .history-item {
    padding: var(--space-lg);
  }
}

/* ============================================
   Tablet (769px - 1024px)
   ============================================ */
@media (min-width: 769px) and (max-width: 1024px) {
  body {
    padding: 0;
    align-items: stretch;
    justify-content: flex-start;
  }

  #app {
    max-width: 100%;
    width: 100%;
    border-radius: 0;
    box-shadow: none;
    margin: 0;
  }

  #app-header {
    padding: 0 var(--space-xl);
    min-height: 60px;
  }

  #main-content {
    padding: var(--space-xl) var(--space-2xl);
    padding-bottom: calc(var(--space-xl) + 80px);
  }

  .welcome-screen {
    padding: var(--space-2xl);
    max-width: 680px;
    margin: 0 auto;
  }

  .welcome-features {
    max-width: 520px;
    margin-left: auto;
    margin-right: auto;
  }

  .form-row {
    grid-template-columns: 1fr 1fr;
  }

  .card {
    padding: var(--space-xl);
  }

  .modal-content {
    width: 70%;
    max-width: 600px;
    border-radius: var(--radius-2xl);
  }

  .grid-3 {
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-lg);
  }

  .card-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-lg);
  }

  .multi-select-container {
    gap: var(--space-md);
  }

  .multi-select-option {
    padding: 12px 18px;
  }

  .profile-grid {
    gap: 32px;
    margin: 0;
    max-width: none;
  }

  #bottom-nav {
    padding: var(--space-sm) var(--space-xl);
  }

  .nav-item {
    padding: var(--space-sm) var(--space-xl);
    gap: var(--space-sm);
    font-size: var(--font-size-sm);
  }

  .nav-item svg {
    width: 22px;
    height: 22px;
  }
}

/* ============================================
   Desktop (1025px+) — Full sidebar layout
   ============================================ */
@media (min-width: 1025px) {
  :root {
    --sidebar-width: 288px;
    --header-height: 84px;
  }

  body {
    background: linear-gradient(135deg, #0F0C29, #302B63, #24243e);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
    padding: 0;
    align-items: stretch;
    justify-content: flex-start;
    overflow: hidden;
  }

  /* Smooth header: remove flex-shrink jank */
  #app-header {
    flex-shrink: 0;
  }

  /* CSS Grid: header spans both columns, sidebar + main below.
     Using "auto 1fr" so the sidebar column collapses to 0 when hidden (display:none),
     letting #main-content fill the full width during the assessment flow. */
  #app {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-rows: var(--header-height) 1fr;
    grid-template-areas:
      "header header"
      "sidebar main";
    max-width: 100%;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    border-radius: 0;
    box-shadow: none;
    margin: 0;
    contain: none;
    position: relative;
  }

  /* Absolutely-positioned elements (dropdown) stay in flow */
  #dropdown-menu {
    z-index: 500;
    top: calc(var(--header-height) + 4px);
  }

  /* Header: full-width top bar — frosted glass */
  #app-header {
    grid-area: header;
    position: sticky;
    top: 0;
    min-height: var(--header-height);
    padding: 0 var(--space-xl) var(--space-md);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06);
    z-index: 200;
    background: rgba(15, 12, 41, 0.80);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    gap: 0;
  }

  /* Left-align logo within the sidebar-width section of the header */
  .header-logo {
    position: relative;
    left: auto;
    top: auto;
    transform: none;
    height: 100%;
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    justify-content: flex-start;
    align-items: center;
    gap: 10px;
    padding: 0 var(--space-lg);
    border-right: none;
    pointer-events: auto;
    flex-shrink: 0;
  }

  .header-logo-img {
    height: 56px;
    width: auto;
    flex-shrink: 0;
  }

  /* Brand name — gold gradient text */
  .header-brand-name {
    display: block;
    font-size: 20px;
    font-weight: 800;
    background: linear-gradient(90deg, #F5B642, #F97316);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.2px;
    line-height: 1.35;
    white-space: normal;
  }

  /* Center area: fills space between logo section and user chip */
  .header-center-area {
    display: flex;
    flex: 1;
    align-items: center;
    padding: 0 var(--space-2xl);
    height: 100%;
  }

  .header-page-tagline {
    font-size: 16px;
    font-weight: 500;
    color: rgba(248, 250, 252, 0.55);
    letter-spacing: 0.02em;
  }

  /* User profile chip in header */
  .header-user-chip {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px 8px 10px;
    margin: 0 var(--space-md);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 50px;
    background: rgba(255, 255, 255, 0.07);
    backdrop-filter: blur(10px);
    flex-shrink: 0;
    max-width: 260px;
  }

  .header-user-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    font-weight: 700;
    flex-shrink: 0;
    letter-spacing: 0.02em;
  }

  .header-user-details {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
  }

  .header-user-name {
    font-size: 17px;
    font-weight: 600;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
  }

  .header-switch-btn {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-primary-dark);
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.35);
    cursor: pointer;
    padding: 5px 12px;
    border-radius: 50px;
    transition: all 0.15s ease;
    white-space: nowrap;
    flex-shrink: 0;
    line-height: 1.4;
  }

  .header-switch-btn:hover {
    background: rgba(245, 158, 11, 0.22);
    border-color: var(--color-primary);
    color: #78350F;
  }

  /* Hide three-dot menu button on desktop — all nav lives in the sidebar */
  #btn-menu {
    display: none;
  }

  /* Desktop-only nav items visible in sidebar */
  .nav-desktop-only {
    display: flex;
  }

  /* Sidebar bottom actions section */
  .nav-bottom-actions {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: auto;
    padding-bottom: var(--space-sm);
    border-top: 1px solid rgba(255, 255, 255, 0.07);
    padding-top: var(--space-sm);
  }

  /* Individual action buttons: About ATM, Sign Out */
  .nav-action-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 14px;
    width: 100%;
    padding: 12px 18px;
    border-radius: 0 var(--radius-xl) var(--radius-xl) 0;
    background: none;
    border: none;
    cursor: pointer;
    color: rgba(248, 250, 252, 0.58);
    font-size: 19px;
    font-weight: 500;
    letter-spacing: 0.01em;
    text-align: left;
    transition: background 0.18s ease, color 0.18s ease;
    min-height: 50px;
  }

  .nav-action-item svg {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    opacity: 0.6;
    transition: opacity 0.18s ease;
  }

  .nav-action-item:hover {
    background: rgba(255, 255, 255, 0.06);
    color: rgba(248, 250, 252, 0.85);
  }

  .nav-action-item:hover svg {
    opacity: 1;
  }

  /* Sign Out: red-tinted on hover */
  .nav-action-logout {
    color: rgba(248, 250, 252, 0.45);
  }

  .nav-action-logout:hover {
    background: rgba(239, 68, 68, 0.12);
    color: #FCA5A5;
  }

  .nav-action-logout:hover svg {
    opacity: 1;
    color: #FCA5A5;
  }

  /* Sidebar: transform bottom-nav into left sidebar — frosted glass */
  #bottom-nav {
    grid-area: sidebar;
    position: static;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    padding: var(--space-lg) var(--space-sm) var(--space-md);
    border-top: none;
    border-right: 1px solid rgba(255, 255, 255, 0.07);
    height: 100%;
    min-height: 0;
    overflow-y: auto;
    gap: 2px;
    background: rgba(15, 12, 41, 0.60);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    max-width: var(--sidebar-width);
  }

  /* No footer line in sidebar */
  #bottom-nav::after {
    content: none;
    display: none;
  }

  /* Nav items: horizontal icon+label rows in sidebar */
  .nav-item {
    flex-direction: row;
    justify-content: flex-start;
    padding: 14px 20px;
    border-radius: 0 var(--radius-xl) var(--radius-xl) 0;
    gap: 15px;
    width: 100%;
    min-height: 56px;
    text-align: left;
    color: rgba(248, 250, 252, 0.75);
    font-weight: 500;
    transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
    margin: 1px 0;
  }

  .nav-item span {
    font-size: var(--font-size-lg);
    font-weight: 600;
    letter-spacing: 0.01em;
  }

  .nav-item svg {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    opacity: 0.70;
    transition: opacity 0.18s ease, stroke-width 0.18s ease;
  }

  /* Active: gold glow + inset accent bar */
  .nav-item.active {
    background: linear-gradient(105deg, rgba(245, 182, 66, 0.18) 0%, rgba(245, 182, 66, 0.06) 100%);
    color: #F5B642;
    box-shadow: inset 4px 0 0 #F5B642;
    font-weight: 700;
  }

  .nav-item.active span {
    font-weight: 700;
  }

  .nav-item.active svg {
    stroke-width: 2.5;
    color: #F5B642;
    opacity: 1;
  }

  .nav-item.active::after {
    display: none; /* Remove mobile indicator dot in sidebar */
  }

  .nav-item:hover:not(.active) {
    background: rgba(255, 255, 255, 0.06);
    color: rgba(248, 250, 252, 0.85);
  }

  .nav-item:hover:not(.active) svg {
    opacity: 1;
  }

  /* Main content area */
  #main-content {
    grid-area: main;
    padding: var(--space-2xl) var(--space-2xl);
    padding-bottom: var(--space-2xl);
    height: 100%;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    background: transparent;
  }

  /* Constrain screen content width for readability */
  .screen {
    max-width: 960px;
    margin: 0 auto;
    width: 100%;
  }

  /* Buttons */
  .btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
  }

  .card-clickable:hover {
    box-shadow: var(--shadow-card-hover);
  }

  .btn {
    min-height: 48px;
  }

  /* Card layouts */
  .card {
    padding: var(--space-xl);
  }

  .card-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-lg);
  }

  .grid-4 {
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-lg);
  }

  .screen-header {
    margin-bottom: var(--space-2xl);
  }

  /* Profile select: keep flex row tight (do not use grid / margin:auto here) */
  .profile-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 32px;
    margin: 0;
    max-width: none;
  }

  .modal-content {
    width: 60%;
    max-width: 700px;
    border-radius: var(--radius-2xl);
  }

  .multi-select-container {
    gap: var(--space-md);
  }

  .multi-select-option {
    padding: 14px 20px;
  }

  .form-row {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-lg);
  }

  .settings-card {
    max-width: 700px;
    margin: 0 auto;
  }
}

/* ============================================
   Large Desktop (1440px+)
   ============================================ */
@media (min-width: 1440px) {
  :root {
    --sidebar-width: 300px;
    --header-height: 84px;
  }

  #app {
    grid-template-rows: var(--header-height) 1fr;
  }

  #main-content {
    padding: var(--space-3xl) var(--space-3xl);
    padding-bottom: var(--space-3xl);
  }

  .screen {
    max-width: 1080px;
  }

  .welcome-screen {
    max-width: 800px;
  }

  .card {
    padding: var(--space-2xl);
  }
}

/* ============================================
   Extra Large Desktop (1920px+)
   ============================================ */
@media (min-width: 1920px) {
  :root {
    --sidebar-width: 320px;
    --header-height: 88px;
    --font-size-base: 1.0625rem;
    --font-size-lg: 1.1875rem;
    --font-size-xl: 1.375rem;
  }

  #app {
    grid-template-rows: var(--header-height) 1fr;
  }

  .screen {
    max-width: 1200px;
  }

  #main-content {
    padding: var(--space-3xl);
    padding-bottom: var(--space-3xl);
  }
}

/* ============================================
   Landscape Orientation (Mobile/Tablet)
   ============================================ */
@media (max-height: 600px) and (orientation: landscape) {
  .welcome-screen {
    padding-top: var(--space-lg);
    padding-bottom: var(--space-lg);
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
  }

  .welcome-hero {
    margin-bottom: var(--space-md);
    flex: 1 1 50%;
  }

  .welcome-features {
    flex: 1 1 50%;
    margin-bottom: var(--space-md);
    max-width: none;
  }

  .welcome-actions {
    flex: 1 1 100%;
  }

  .logo-circle {
    width: 64px;
    height: 64px;
  }

  .welcome-features {
    margin-bottom: var(--space-lg);
  }

  .feature-item {
    padding: var(--space-xs) var(--space-sm);
  }

  .auth-screen {
    padding: var(--space-md);
    flex-direction: row;
    flex-wrap: wrap;
  }

  .auth-header {
    margin-bottom: var(--space-md);
    flex: 1 1 100%;
  }

  .auth-form {
    flex: 1 1 50%;
    padding-right: var(--space-md);
    max-width: none;
    display: block;
  }

  .auth-screen .auth-form .btn.btn-block {
    width: 100%;
    max-width: none;
    margin-left: 0;
    margin-right: 0;
  }

  /* Bottom nav in landscape */
  #bottom-nav {
    padding: var(--space-xs) 0;
  }

  .nav-item {
    flex-direction: row;
    gap: var(--space-xs);
  }

  /* Profile Grid in landscape — already flex, just adjust gap */
  .profile-grid {
    gap: 40px;
  }

  /* Question card in landscape */
  .question-card {
    display: flex;
    flex-wrap: wrap;
  }

  .question-text {
    flex: 1 1 50%;
  }

  .answer-area {
    flex: 1 1 50%;
  }
}

/* ============================================
   Landscape for tablets
   ============================================ */
@media (min-width: 769px) and (max-height: 600px) and (orientation: landscape) {
  #app {
    max-width: 100%;
    border-radius: 0;
    box-shadow: none;
    height: 100vh;
    height: 100dvh;
  }

  body {
    padding: 0;
  }

  #main-content {
    padding: var(--space-md) var(--space-xl);
    padding-bottom: calc(var(--space-md) + 80px);
  }
}

/* ============================================
   Touch Device Optimizations
   ============================================ */
@media (hover: none) and (pointer: coarse) {
  /* Larger touch targets - minimum 44px x 44px (iOS guidelines) */
  .btn {
    min-height: 44px;
    min-width: 44px;
  }

  .header-btn {
    min-width: 44px;
    min-height: 44px;
  }

  .nav-item {
    min-height: 48px;
    padding: var(--space-sm);
  }

  .otp-input {
    min-width: 48px;
    min-height: 48px;
  }

  .form-input,
  .form-select {
    min-height: 48px;
  }

  .mcq-option,
  .option-btn {
    min-height: 48px;
  }

  .multi-select-option {
    min-height: 44px;
  }

  .menu-item {
    min-height: 48px;
  }

  /* Remove hover effects on touch devices */
  .btn:hover {
    transform: none;
  }

  .card-clickable:hover {
    transform: none;
    box-shadow: var(--shadow-card);
  }

  /* Active states instead of hover */
  .btn:active {
    transform: scale(0.98);
    opacity: 0.9;
  }

  .card-clickable:active {
    transform: scale(0.99);
    box-shadow: var(--shadow-card-hover);
  }

  /* Better scrolling */
  #main-content {
    -webkit-overflow-scrolling: touch;
  }

  /* Disable text selection on interactive elements */
  .btn, .nav-item, .menu-item, .card-clickable {
    -webkit-user-select: none;
    user-select: none;
  }
}

/* ============================================
   High DPI / Retina Displays
   ============================================ */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .logo-circle {
    box-shadow: 0 8px 32px rgba(245, 182, 66, 0.4);
  }

  .card {
    border: 0.5px solid var(--color-border);
  }

  /* Sharper borders */
  .form-input,
  .form-select,
  .btn-secondary {
    border-width: 1.5px;
  }
}

/* ============================================
   Print Styles
   ============================================ */
@media print {
  #app-header,
  #bottom-nav,
  .btn,
  .header-btn,
  .voice-input-container {
    display: none !important;
  }

  #app {
    max-width: 100%;
    box-shadow: none;
    border-radius: 0;
  }

  #main-content {
    padding: 0;
    padding-bottom: 0;
  }

  .card {
    page-break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ccc;
  }

  .question-card {
    page-break-inside: avoid;
  }

  body {
    background: white;
    padding: 0;
  }
}

/* ============================================
   Accessibility - Reduced Motion
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .btn:hover,
  .card:hover {
    transform: none !important;
  }
}

/* ============================================
   High Contrast Mode
   ============================================ */
@media (prefers-contrast: high) {
  :root {
    --color-border: #000;
    --color-text-secondary: #333;
    --color-text-muted: #555;
  }

  .btn {
    border: 2px solid currentColor;
  }

  .card {
    border: 2px solid var(--color-border);
  }

  .form-input,
  .form-select {
    border: 2px solid var(--color-border);
  }
}

/* ============================================
   Dark Mode Support (Future)
   ============================================ */
@media (prefers-color-scheme: dark) {
  /* Dark mode styles can be added here */
  /* Currently using light theme by default */
}

/* ============================================
   Responsive Utility Classes
   ============================================ */

/* Hide on mobile */
.hide-mobile {
  display: none;
}

@media (min-width: 769px) {
  .hide-mobile {
    display: block;
  }
}

/* Hide on desktop */
.hide-desktop {
  display: block;
}

@media (min-width: 769px) {
  .hide-desktop {
    display: none;
  }
}

/* Show only on mobile */
.show-mobile-only {
  display: block;
}

@media (min-width: 481px) {
  .show-mobile-only {
    display: none;
  }
}

/* Show only on tablet and up */
.show-tablet-up {
  display: none;
}

@media (min-width: 769px) {
  .show-tablet-up {
    display: block;
  }
}

/* Responsive text alignment */
@media (max-width: 480px) {
  .text-center-mobile {
    text-align: center;
  }

  .text-left-mobile {
    text-align: left;
  }
}

/* Responsive spacing */
.spacing-responsive {
  padding: var(--space-md);
}

@media (min-width: 769px) {
  .spacing-responsive {
    padding: var(--space-xl);
  }
}

/* Responsive grid */
.grid-responsive {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-md);
}

@media (min-width: 481px) {
  .grid-responsive {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1025px) {
  .grid-responsive {
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-lg);
  }
}

/* Flex responsive */
.flex-responsive {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

@media (min-width: 769px) {
  .flex-responsive {
    flex-direction: row;
    flex-wrap: wrap;
  }
}

/* Container max-widths */
.container-sm {
  max-width: 100%;
  margin: 0 auto;
  padding: 0 var(--space-md);
}

@media (min-width: 481px) {
  .container-sm {
    max-width: 420px;
  }
}

@media (min-width: 769px) {
  .container-sm {
    max-width: 600px;
  }
}

@media (min-width: 1025px) {
  .container-sm {
    max-width: 700px;
  }
}

.container-md {
  max-width: 100%;
  margin: 0 auto;
  padding: 0 var(--space-md);
}

@media (min-width: 481px) {
  .container-md {
    max-width: 540px;
  }
}

@media (min-width: 769px) {
  .container-md {
    max-width: 720px;
  }
}

@media (min-width: 1025px) {
  .container-md {
    max-width: 900px;
  }
}

/* Flexible images */
img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Responsive tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
  .table-responsive table {
    min-width: 600px;
  }
}

/* Stack on mobile */
.stack-mobile {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

@media (min-width: 481px) {
  .stack-mobile {
    flex-direction: row;
    align-items: center;
  }
}

/* Full width on mobile */
.full-width-mobile {
  width: 100%;
}

@media (min-width: 481px) {
  .full-width-mobile {
    width: auto;
  }
}

/* Responsive padding */
.p-responsive {
  padding: var(--space-sm);
}

@media (min-width: 481px) {
  .p-responsive {
    padding: var(--space-md);
  }
}

@media (min-width: 769px) {
  .p-responsive {
    padding: var(--space-lg);
  }
}

@media (min-width: 1025px) {
  .p-responsive {
    padding: var(--space-xl);
  }
}

/* Responsive margin */
.m-responsive {
  margin: var(--space-sm);
}

@media (min-width: 481px) {
  .m-responsive {
    margin: var(--space-md);
  }
}

@media (min-width: 769px) {
  .m-responsive {
    margin: var(--space-lg);
  }
}

/* Responsive gap */
.gap-responsive {
  gap: var(--space-sm);
}

@media (min-width: 481px) {
  .gap-responsive {
    gap: var(--space-md);
  }
}

@media (min-width: 769px) {
  .gap-responsive {
    gap: var(--space-lg);
  }
}

/* Truncate text */
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Line clamp for multi-line truncation */
.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.line-clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Safe area insets for notched devices */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  #bottom-nav {
    padding-bottom: calc(var(--space-sm) + env(safe-area-inset-bottom));
  }

  .modal-content {
    padding-bottom: calc(var(--space-lg) + env(safe-area-inset-bottom));
  }

  .action-bar {
    padding-bottom: calc(var(--space-md) + env(safe-area-inset-bottom));
  }
}

@supports (padding-top: env(safe-area-inset-top)) {
  #app-header {
    padding-top: calc(var(--space-md) + env(safe-area-inset-top));
  }
}

/* Focus visible for keyboard navigation */
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Remove focus outline for mouse users */
:focus:not(:focus-visible) {
  outline: none;
}

/* ============================================
   ATM Logo Responsive Styles
   ============================================ */

@media (max-width: 768px) {
  .header-logo {
    height: 30px;
  }
  
  .header-logo-img {
    height: 28px;
  }
  
  .logo-circle .logo-img {
    max-width: 64px;
  }
  
  .logo-circle.small .logo-img {
    max-width: 42px;
  }
}

@media (max-width: 480px) {
  .header-logo {
    height: 26px;
  }
  
  .header-logo-img {
    height: 26px;
  }
  
  .logo-circle {
    width: 80px;
    height: 80px;
  }
  
  .logo-circle .logo-img {
    max-width: 56px;
  }
  
  .logo-circle.small {
    width: 56px;
    height: 56px;
  }
  
  .logo-circle.small .logo-img {
    max-width: 36px;
  }
}
