/* 
 * Medal Order Form Stylesheet
 * Optimized for RTL support, accessibility, and responsive design
 */

/* ===== BASE STYLES ===== */
:root {
  /* Color palette */
  --primary: #d5a273;
  --primary-dark: #c08b5d;
  --primary-darker: #a67748;
  --text-dark: #333;
  --text-light: #fff;
  --error: #d32f2f;
  --success: #4caf50;
  --border: #ddd;
  --background-light: rgba(255, 255, 255, 0.8);
  --background-dark: rgba(0, 0, 0, 0.7);
  
  /* Spacing */
  --spacing-xs: 5px;
  --spacing-sm: 10px;
  --spacing-md: 20px;
  --spacing-lg: 30px;
  
  /* Border radius */
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 18px;
  
  /* Z-index layers */
  --z-dropdown: 100;
  --z-overlay: 900;
  --z-modal: 1000;
}

/* Reset and base styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  background-image: url('background-image.jpg');
  background-size: cover;
  background-attachment: fixed;
  background-position: center;
  /* Add a fallback background color */
  background-color: #f5f5f5;
  font-family: Arial, sans-serif;
  color: var(--text-dark);
  min-height: 100vh;
  line-height: 1.5;
}

/* ===== LAYOUT ===== */
header {
  background-color: var(--primary);
  color: var(--text-light);
  padding: var(--spacing-md);
  text-align: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  position: relative;
}

header h1 {
  font-size: 2rem;
  margin: 0;
}

main {
  max-width: 700px;
  margin: var(--spacing-lg) auto;
  background: var(--background-light);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px); /* Safari support */
  padding: var(--spacing-lg);
  border-radius: var(--radius-md);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

footer {
  background-color: #000;
  text-align: center;
  padding: var(--spacing-sm) 0;
  font-size: 0.875rem;
  color: var(--text-light);
  margin-top: var(--spacing-lg);
}

/* ===== RTL SUPPORT ===== */
/* Apply RTL direction to the entire form */
#order-form {
  direction: rtl;
}

.form-group {
  margin-bottom: var(--spacing-md);
  text-align: right;
}

label {
  display: block;
  margin-bottom: var(--spacing-xs);
  font-weight: bold;
  color: var(--text-dark);
}

input, textarea, select, button {
  width: 100%;
  padding: var(--spacing-sm);
  font-size: 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin-bottom: var(--spacing-xs);
  text-align: right;
  direction: rtl;
}

/* ===== FORM ELEMENTS ===== */
textarea {
  resize: vertical;
  min-height: 100px;
}

input[type="file"] {
  padding: var(--spacing-xs);
  border: none;
}

button {
  background-color: var(--primary-dark);
  color: var(--text-light);
  border: none;
  cursor: pointer;
  font-weight: bold;
  padding: var(--spacing-sm);
  transition: background-color 0.3s ease;
  margin-top: var(--spacing-sm);
}

button:hover {
  background-color: var(--primary-darker);
}

/* ===== ACCESSIBILITY FOCUS STATES ===== */
input:focus, 
textarea:focus, 
select:focus,
button:focus {
  outline: 3px solid var(--primary-darker);
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(213, 162, 115, 0.3);
}

/* High contrast focus for keyboard navigation */
button:focus-visible {
  outline: 3px solid var(--primary-darker);
  outline-offset: 2px;
}

/* ===== FORM VALIDATION ===== */
.error-message {
  color: var(--error);
  font-weight: bold;
  display: block;
  font-size: 0.875rem;
  margin-top: var(--spacing-xs);
}

/* Visual feedback for validation states */
input:invalid:not(:focus):not(:placeholder-shown),
textarea:invalid:not(:focus):not(:placeholder-shown) {
  border-color: var(--error);
  background-color: rgba(211, 47, 47, 0.05);
}

input:valid:not(:placeholder-shown),
textarea:valid:not(:placeholder-shown) {
  border-color: var(--success);
  background-color: rgba(76, 175, 80, 0.05);
}

/* ===== LOGO ===== */
.logo-container {
  display: flex;
  justify-content: center;
  margin-bottom: var(--spacing-md);
}

.logo {
  max-width: 150px;
  height: auto;
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* ===== DROPDOWN MENU ===== */
.dropdown {
  position: absolute;
  top: var(--spacing-md);
  right: var(--spacing-md);
}

.dropbtn {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-light);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: auto;
  margin: 0;
  padding: var(--spacing-xs);
}

.dropbtn::before {
  content: '⋮';
  font-size: 1.5rem;
}

.dropdown-content {
  display: none;
  position: absolute;
  top: 40px;
  right: 0;
  background-color: var(--text-light);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  z-index: var(--z-dropdown);
  min-width: 120px;
}

.dropdown-content a {
  color: var(--text-dark);
  padding: var(--spacing-sm);
  text-decoration: none;
  display: block;
  text-align: left;
}

.dropdown-content a:hover {
  background-color: var(--primary);
  color: var(--text-light);
}

.dropdown:hover .dropdown-content,
.dropdown:focus-within .dropdown-content {
  display: block;
}

/* ===== CONFIRMATION BOX ===== */
.confirmation-box {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--text-light);
  padding: var(--spacing-lg);
  border-radius: var(--radius-md);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
  text-align: center;
  max-width: 500px;
  width: 90%;
  z-index: var(--z-modal);
}

.confirmation-box h2 {
  color: var(--primary);
  margin-bottom: var(--spacing-md);
}

.order-number {
  font-size: 1.5rem;
  margin: var(--spacing-md) 0;
  color: var(--text-dark);
}

.order-number span {
  font-weight: bold;
  color: var(--primary);
}

/* ===== LOADING OVERLAY ===== */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: var(--background-dark);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: var(--z-overlay);
}

.upload-status {
  text-align: center;
  color: var(--text-light);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 5px solid rgba(255, 255, 255, 0.3);
  border-top-color: var(--text-light);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto var(--spacing-md);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== RESPONSIVE DESIGN ===== */
/* Tablet */
@media (max-width: 768px) {
  main {
    margin: var(--spacing-md);
    padding: var(--spacing-md);
  }
  
  header h1 {
    font-size: 1.5rem;
  }
  
  .logo {
    max-width: 120px;
  }
  
  .confirmation-box {
    padding: var(--spacing-md);
  }
}

/* Mobile */
@media (max-width: 480px) {
  main {
    margin: var(--spacing-sm);
    padding: var(--spacing-md);
  }
  
  header h1 {
    font-size: 1.25rem;
  }
  
  input, textarea, button {
    padding: var(--spacing-sm);
  }
  
  .confirmation-box {
    padding: var(--spacing-md);
    width: 95%;
  }
  
  .order-number {
    font-size: 1.25rem;
  }
  
  .dropdown {
    top: var(--spacing-sm);
    right: var(--spacing-sm);
  }
}

/* Small Mobile */
@media (max-width: 320px) {
  main {
    padding: var(--spacing-sm);
  }
  
  header h1 {
    font-size: 1.1rem;
  }
  
  .logo {
    max-width: 100px;
  }
  
  .form-group {
    margin-bottom: var(--spacing-sm);
  }
  
  .confirmation-box h2 {
    font-size: 1.2rem;
  }
}

/* ===== PRINT STYLES ===== */
@media print {
  body {
    background: none;
  }
  
  main {
    box-shadow: none;
    margin: 0;
    padding: 0;
  }
  
  .dropdown, button {
    display: none;
  }
}

/* ===== FORCED COLORS MODE ===== */
@media (forced-colors: active) {
  button {
    border: 2px solid ButtonText;
  }
  
  input:focus, textarea:focus, button:focus {
    outline: 2px solid Highlight;
  }
}

/* ===== REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
