/*
 Theme Name:   DPT Hello Child
 Theme URI:    http://localhost/dronePilot
 Description:  Child theme for Drone Pilot Test, built on Hello Elementor.
 Author:       Precision Agriculture Education
 Author URI:   http://localhost/dronePilot
 Template:     hello-elementor
 Version:      1.0.0
 License:      GNU General Public License v2 or later
 License URI:  http://www.gnu.org/licenses/gpl-2.0.html
 Text Domain:  dpt-hello-child
*/

/* ============================================================
   Design Tokens (from DPT Design Packet)
   ============================================================ */

:root {
  /* Primary */
  --dpt-primary: #0B5ED7;
  --dpt-primary-hover: #1E78FF;
  --dpt-primary-soft: #B9D7FF;

  /* Success / Correct */
  --dpt-success: #137A3A;
  --dpt-success-hover: #1B9A4A;
  --dpt-success-soft: #BFE8CD;

  /* Accents */
  --dpt-olive: #3F5B3A;

  /* Warning */
  --dpt-warning-bg: #D38B22;
  --dpt-warning-light: #FEF3C7;
  --dpt-warning-text: #92400E;

  /* Error */
  --dpt-error-bg: #D64045;
  --dpt-error-text: #B91C1C;
  --dpt-error-light: #FEE2E2;

  /* Surfaces */
  --dpt-surface: #FFFFFF;
  --dpt-surface-alt: #F0F4FA;
  --dpt-page-bg: #F4F7FB;
  --dpt-border: #D9E2EF;

  /* Text */
  --dpt-text: #0F172A;
  --dpt-text-secondary: #475569;

  /* Component */
  --dpt-radius: 14px;
  --dpt-radius-sm: 8px;
  --dpt-radius-xs: 6px;
  --dpt-input-height: 44px;
  --dpt-transition-fast: 150ms ease;
  --dpt-transition-base: 200ms ease;

  /* Spacing (8px base) */
  --dpt-space-1: 4px;
  --dpt-space-2: 8px;
  --dpt-space-3: 12px;
  --dpt-space-4: 16px;
  --dpt-space-5: 20px;
  --dpt-space-6: 24px;
  --dpt-space-7: 28px;
  --dpt-space-8: 32px;
  --dpt-space-10: 40px;
  --dpt-space-12: 48px;
}

/* Dark mode overrides */
[data-theme="dark"] {
  --dpt-surface: #1E293B;
  --dpt-surface-alt: #334155;
  --dpt-page-bg: #0F172A;
  --dpt-text: #F1F5F9;
  --dpt-text-secondary: #94A3B8;
  --dpt-border: #334155;
  --dpt-primary: #3B82F6;
  --dpt-primary-hover: #60A5FA;
  --dpt-primary-soft: #1E3A5F;
  --dpt-success-soft: #065F25;
  --dpt-warning-light: #451A03;
  --dpt-warning-text: #FCD34D;
  --dpt-error-light: #450A0A;
}

/* ============================================================
   Base Styles
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Rubik:wght@300;400;500;600;700&display=swap');

*, *::before, *::after {
  box-sizing: border-box;
}

body {
  font-family: 'Rubik', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background-color: var(--dpt-page-bg);
  color: var(--dpt-text);
  direction: rtl;
  line-height: 1.6;
  font-size: 16px;
}

/* Typography scale */
h1 { font-size: 32px; font-weight: 700; line-height: 1.2; }
h2 { font-size: 24px; font-weight: 600; line-height: 1.3; }
h3 { font-size: 20px; font-weight: 600; line-height: 1.4; }
small, .dpt-text-sm { font-size: 14px; }
.dpt-text-xs { font-size: 12px; }

a {
  color: var(--dpt-primary);
  text-decoration: none;
  transition: color var(--dpt-transition-fast);
}

a:hover {
  color: var(--dpt-primary-hover);
}

/* Focus ring for accessibility */
*:focus-visible {
  outline: 2px solid var(--dpt-primary);
  outline-offset: 2px;
}

/* ============================================================
   Layout
   ============================================================ */

.dpt-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--dpt-space-6);
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--dpt-space-6);
}

.dpt-grid--2col {
  display: grid;
  gap: var(--dpt-space-5);
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.dpt-grid--3col {
  display: grid;
  gap: var(--dpt-space-5);
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.dpt-test-layout {
  display: grid;
  gap: var(--dpt-space-6);
}

@media (min-width: 1024px) {
  .dpt-test-layout {
    grid-template-columns: 1fr 280px;
  }
}

/* Flex utilities */
.dpt-flex { display: flex; }
.dpt-flex--col { flex-direction: column; }
.dpt-flex--wrap { flex-wrap: wrap; }
.dpt-flex--between { justify-content: space-between; }
.dpt-flex--center { align-items: center; }
.dpt-flex--gap { gap: var(--dpt-space-4); }

/* RTL-safe text alignment */
.dpt-text-start { text-align: start; }
.dpt-text-end { text-align: end; }
.dpt-text-center { text-align: center; }

/* ============================================================
   Components
   ============================================================ */

/* Cards */
.dpt-card {
  background: var(--dpt-surface);
  border: 1px solid var(--dpt-border);
  border-radius: var(--dpt-radius);
  padding: var(--dpt-space-6);
  transition: box-shadow var(--dpt-transition-base);
}

.dpt-card:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.dpt-card__header {
  margin-bottom: var(--dpt-space-4);
  padding-bottom: var(--dpt-space-3);
  border-bottom: 1px solid var(--dpt-border);
}

/* Buttons */
.dpt-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--dpt-space-2);
  padding: 12px 20px;
  border-radius: 10px;
  border: none;
  font-family: inherit;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color var(--dpt-transition-fast), box-shadow var(--dpt-transition-fast);
  line-height: 1;
}

.dpt-btn--primary {
  background-color: var(--dpt-primary);
  color: #FFFFFF;
}

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

.dpt-btn--secondary {
  background-color: var(--dpt-surface);
  color: var(--dpt-text);
  border: 1px solid var(--dpt-border);
}

.dpt-btn--secondary:hover {
  background-color: var(--dpt-surface-alt);
}

.dpt-btn--ghost {
  background: transparent;
  color: var(--dpt-primary);
}

.dpt-btn--ghost:hover {
  background-color: var(--dpt-primary-soft);
}

.dpt-btn--destructive {
  background-color: var(--dpt-error-bg);
  color: #FFFFFF;
}

.dpt-btn--destructive:hover {
  background-color: #B91C1C;
}

.dpt-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Form inputs */
.dpt-input {
  display: block;
  width: 100%;
  height: var(--dpt-input-height);
  padding: var(--dpt-space-3) var(--dpt-space-4);
  background: var(--dpt-surface);
  border: 1px solid var(--dpt-border);
  border-radius: var(--dpt-radius-sm);
  font-family: inherit;
  font-size: 16px;
  color: var(--dpt-text);
  transition: border-color var(--dpt-transition-fast), box-shadow var(--dpt-transition-fast);
}

.dpt-input:focus {
  border-color: var(--dpt-primary);
  box-shadow: 0 0 0 3px var(--dpt-primary-soft);
  outline: none;
}

.dpt-input--error {
  border-color: var(--dpt-error-bg);
}

.dpt-input--error:focus {
  box-shadow: 0 0 0 3px var(--dpt-error-light);
}

/* Badges */
.dpt-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--dpt-radius-xs);
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
}

.dpt-badge--draft {
  background: var(--dpt-surface-alt);
  color: var(--dpt-text-secondary);
}

.dpt-badge--review {
  background: var(--dpt-warning-light);
  color: var(--dpt-warning-text);
}

.dpt-badge--published {
  background: var(--dpt-success-soft);
  color: #065F25;
}

.dpt-badge--correct {
  background: var(--dpt-success-soft);
  color: var(--dpt-success);
}

.dpt-badge--incorrect {
  background: var(--dpt-error-light);
  color: var(--dpt-error-text);
}

/* Progress bar */
.dpt-progress {
  width: 100%;
  height: 8px;
  background: var(--dpt-surface-alt);
  border-radius: 4px;
  overflow: hidden;
}

.dpt-progress__fill {
  height: 100%;
  background: var(--dpt-success);
  border-radius: 4px;
  transition: width var(--dpt-transition-base);
}

/* Tables (responsive, RTL-safe) */
.dpt-table {
  width: 100%;
  border-collapse: collapse;
  text-align: start;
}

.dpt-table th {
  font-weight: 600;
  padding: var(--dpt-space-3) var(--dpt-space-4);
  border-bottom: 2px solid var(--dpt-border);
  white-space: nowrap;
  color: var(--dpt-text-secondary);
  font-size: 14px;
}

.dpt-table td {
  padding: var(--dpt-space-3) var(--dpt-space-4);
  border-bottom: 1px solid var(--dpt-border);
  vertical-align: middle;
}

.dpt-table__actions {
  text-align: end;
  white-space: nowrap;
}

@media (max-width: 768px) {
  .dpt-table--responsive thead {
    display: none;
  }

  .dpt-table--responsive tr {
    display: block;
    margin-bottom: var(--dpt-space-3);
    background: var(--dpt-surface);
    border: 1px solid var(--dpt-border);
    border-radius: var(--dpt-radius);
    padding: var(--dpt-space-4);
  }

  .dpt-table--responsive td {
    display: flex;
    justify-content: space-between;
    padding: var(--dpt-space-1) 0;
    border: none;
  }

  .dpt-table--responsive td::before {
    content: attr(data-label);
    font-weight: 600;
    margin-inline-end: var(--dpt-space-3);
  }
}

/* Timer */
.dpt-timer {
  font-size: 20px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--dpt-text);
}

.dpt-timer--warning {
  color: var(--dpt-warning-bg);
}

.dpt-timer--critical {
  color: var(--dpt-error-bg);
  animation: dpt-pulse 1s ease-in-out infinite;
}

@keyframes dpt-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Question option */
.dpt-question__option {
  display: flex;
  align-items: flex-start;
  gap: var(--dpt-space-3);
  padding: var(--dpt-space-4);
  border: 2px solid var(--dpt-border);
  border-radius: var(--dpt-radius-sm);
  cursor: pointer;
  transition: border-color var(--dpt-transition-fast), background-color var(--dpt-transition-fast);
}

.dpt-question__option:hover {
  border-color: var(--dpt-primary-soft);
  background-color: var(--dpt-surface-alt);
}

.dpt-question__option--selected {
  border-color: var(--dpt-primary);
  background-color: var(--dpt-primary-soft);
}

.dpt-question__option--correct {
  border-color: var(--dpt-success);
  background-color: var(--dpt-success-soft);
}

.dpt-question__option--incorrect {
  border-color: var(--dpt-error-bg);
  background-color: var(--dpt-error-light);
}

/* Question navigation grid */
.dpt-question-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: var(--dpt-space-2);
}

.dpt-question-grid__item {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--dpt-radius-xs);
  border: 1px solid var(--dpt-border);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color var(--dpt-transition-fast);
}

.dpt-question-grid__item--current {
  background: var(--dpt-primary);
  color: #FFFFFF;
  border-color: var(--dpt-primary);
}

.dpt-question-grid__item--answered {
  background: var(--dpt-success-soft);
  border-color: var(--dpt-success);
  color: var(--dpt-success);
}

.dpt-question-grid__item--flagged {
  background: var(--dpt-warning-light);
  border-color: var(--dpt-warning-bg);
  color: var(--dpt-warning-text);
}

/* Toast notification */
.dpt-toast {
  position: fixed;
  top: var(--dpt-space-6);
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  padding: var(--dpt-space-3) var(--dpt-space-6);
  border-radius: var(--dpt-radius-sm);
  font-weight: 500;
  z-index: 9999;
  opacity: 0;
  transition: opacity var(--dpt-transition-base), transform var(--dpt-transition-base);
}

.dpt-toast--visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.dpt-toast--success {
  background: var(--dpt-success);
  color: #FFFFFF;
}

.dpt-toast--error {
  background: var(--dpt-error-bg);
  color: #FFFFFF;
}
