* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary-color: #006400;
  --primary-dark: #004d00;
  --secondary-color: #C9A227;
  --accent-color: #E8F5E9;
  --bg-light: #F0FDF4;
  --bg-white: #FFFFFF;
  --text-primary: #1B5E20;
  --text-secondary: #558B2F;
  --border-color: #C8E6C9;
  --shadow-sm: 0 2px 4px rgba(0, 100, 0, 0.05);
  --shadow-md: 0 4px 6px rgba(0, 100, 0, 0.07);
  --shadow-lg: 0 10px 15px rgba(0, 100, 0, 0.1);
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background-color: var(--bg-light);
  color: var(--text-primary);
  line-height: 1.6;
}

.app-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.header {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
  color: white;
  padding: 1.5rem 1rem 1rem;
  box-shadow: var(--shadow-md);
  position: relative;
  direction: ltr;
  text-align: left;
}

.header-content {
  max-width: 600px;
  margin: 0 auto;
  text-align: center;
  padding: 0 4rem;
}

.title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin: 0 0 0.375rem 0;
  line-height: 1.3;
}

.subtitle {
  font-size: 0.85rem;
  opacity: 0.9;
  font-weight: 400;
  margin: 0;
}

/* Language Switcher Button */
.lang-switcher {
  position: absolute;
  top: 50%;
  right: 1rem;
  transform: translateY(-50%);
  width: 56px;
  height: 28px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 14px;
  padding: 2px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
  text-decoration: none;
  display: block;
  z-index: 100;
  -webkit-tap-highlight-color: transparent;
}

.lang-switcher:hover {
  background: rgba(255, 255, 255, 0.5);
  transform: translateY(-50%) scale(1.05);
}

.lang-switcher:active {
  transform: translateY(-50%) scale(0.95);
}

.lang-toggle-slider {
  width: 24px;
  height: 24px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform 0.3s ease;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--primary-color);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* LTR: English page, slider on left */
.ltr .lang-toggle-slider {
  transform: translateX(0);
}

/* RTL: Arabic page, slider on right */
.rtl .lang-toggle-slider {
  transform: translateX(28px);
}

.main-content {
  flex: 1;
  padding: 1.5rem 1rem;
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
}

.section-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--border-color);
}

.input-section {
  background: var(--bg-white);
  border-radius: 1rem;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

.form-input, .form-select {
  width: 100%;
  padding: 0.875rem 1rem;
  border: 2px solid var(--border-color);
  border-radius: 0.75rem;
  font-size: 1rem;
  font-family: inherit;
  transition: all 0.2s ease;
  background-color: var(--bg-light);
}

.form-input:focus, .form-select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(0, 82, 155, 0.1);
}

.form-input::placeholder {
  color: var(--text-secondary);
}

.form-select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-size: 1rem;
  padding-right: 2.5rem;
}

.form-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.form-row .form-group {
  flex: 1;
  min-width: 120px;
}

.form-row.date-row {
  flex-wrap: nowrap;
}

.form-row.date-row .form-group {
  flex: 1;
  min-width: 0;
}

.form-row.date-row .form-input {
  text-align: center;
}

.form-row.manual-row {
  flex-wrap: nowrap;
}

.form-row.manual-row .form-group {
  flex: 1;
  min-width: 0;
}

.form-row.manual-row .form-input {
  text-align: center;
}

.date-input {
  font-family: inherit;
  height: 3.2rem;
  box-sizing: border-box;
  padding: 0.875rem 1rem;
  position: relative;
}

.form-input[type="date"] {
  height: 3.2rem;
  padding: 0.875rem 1rem;
  line-height: 1.2;
}

/* Force date input placeholder to show yyyy-mm-dd */
.form-input[type="date"]:required:invalid::-webkit-datetime-edit {
  color: transparent;
}

.form-input[type="date"]:focus::-webkit-datetime-edit {
  color: var(--text-primary) !important;
}

.form-input[type="date"]::placeholder {
  color: var(--text-secondary);
  opacity: 1;
}

/* Hide default date placeholder text */
.form-input[type="date"]:not(:focus):not(:valid)::-webkit-datetime-edit {
  color: transparent;
}

.form-input[type="date"]:not(:focus):not(:valid)::before {
  content: attr(placeholder);
  color: var(--text-secondary);
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}

.form-input[type="text"],
.form-input[type="number"] {
  height: 3.2rem;
  line-height: 1.2;
}

.service-period-container {
  background: var(--bg-light);
  border-radius: 0.75rem;
  padding: 0.375rem;
  min-height: 120px;
}

.service-period-content {
  min-height: 80px;
}

.service-type-group {
  display: flex;
  gap: 0.5rem;
}

.service-type-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1rem;
  border: 2px solid transparent;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.875rem;
  font-weight: 500;
  background: transparent;
  color: var(--text-secondary);
}

.service-type-btn:hover {
  background: rgba(0, 82, 155, 0.05);
}

.service-type-btn.active {
  background: var(--bg-white);
  border-color: var(--primary-color);
  color: var(--primary-color);
  box-shadow: var(--shadow-sm);
}

.service-type-btn input[type="radio"] {
  display: none;
}

.calculate-btn {
  width: 100%;
  padding: 1rem;
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
  color: white;
  border: none;
  border-radius: 0.75rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-md);
}

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

.calculate-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.result-section {
  background: var(--bg-white);
  border-radius: 1rem;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.result-card {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
  border-radius: 0.75rem;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  color: white;
}

.result-amount {
  text-align: center;
  margin-bottom: 1rem;
}

.amount-label {
  display: block;
  font-size: 0.875rem;
  opacity: 0.9;
  margin-bottom: 0.5rem;
}

.amount-value {
  display: block;
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -1px;
}

.full-gratuity {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 0.5rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.full-gratuity-value {
  font-weight: 600;
  text-decoration: line-through;
  opacity: 0.8;
}

.result-info {
  text-align: center;
}

.explanation {
  font-size: 0.875rem;
  opacity: 0.95;
}

.breakdown-section {
  margin-bottom: 1.5rem;
}

.breakdown-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 1rem;
}

.service-summary {
  background: var(--bg-light);
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.breakdown-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.breakdown-item {
  background: var(--bg-light);
  border-radius: 0.5rem;
  padding: 1rem;
}

.breakdown-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.25rem;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.breakdown-period {
  font-size: 0.875rem;
  color: var(--text-primary);
  font-weight: 500;
}

.breakdown-sublabel {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 400;
}

.breakdown-rate {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.breakdown-amount {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--primary-color);
}

.base-info {
  background: var(--bg-light);
  border-radius: 0.5rem;
  padding: 1rem;
  margin-top: 1rem;
}

.base-info p {
  font-size: 0.875rem;
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
}

.base-info p:last-child {
  margin-bottom: 0;
}

.disclaimer {
  background: #FEF3C7;
  border-left: 4px solid #F59E0B;
  border-radius: 0.5rem;
  padding: 1rem;
}

.disclaimer p {
  font-size: 0.8rem;
  color: #92400E;
  line-height: 1.5;
}

.info-section {
  background: var(--bg-white);
  border-radius: 1rem;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.info-content h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--primary-color);
  margin-top: 1.25rem;
  margin-bottom: 0.75rem;
}

.info-content h3:first-child {
  margin-top: 0;
}

.info-content ul {
  list-style: none;
  padding-left: 0;
}

.info-content li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.info-content li:last-child {
  border-bottom: none;
}

.info-content p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.faq-section {
  background: var(--bg-white);
  border-radius: 1rem;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.faq-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.faq-item {
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  overflow: hidden;
}

.faq-question {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  background: var(--bg-light);
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
  text-align: left;
  gap: 1rem;
}

.faq-icon {
  font-size: 1.25rem;
  font-weight: 300;
  color: var(--primary-color);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.faq-icon.expanded {
  transform: rotate(45deg);
}

.faq-answer {
  padding: 1rem;
  background: white;
  border-top: 1px solid var(--border-color);
}

.faq-answer p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.footer {
  background: var(--text-primary);
  color: white;
  text-align: center;
  padding: 1.5rem;
  margin-top: auto;
}

.footer-text {
  font-size: 0.875rem;
  opacity: 0.8;
  margin: 0 0 0.5rem 0;
}

.legal-basis {
  font-size: 0.75rem;
  opacity: 0.6;
  margin: 0;
  font-style: italic;
}

.rtl .form-input,
.rtl .form-select,
.rtl .radio-label {
  text-align: right;
}

.rtl .form-row {
  direction: rtl;
}

.rtl .service-type-group {
  flex-direction: row-reverse;
}

.rtl .breakdown-header {
  flex-direction: row-reverse;
}

.rtl .disclaimer {
  border-left: none;
  border-right: 4px solid #F59E0B;
}

.rtl .base-info p {
  text-align: right;
}

.rtl .info-content ul {
  padding-left: 0;
  padding-right: 0;
}

.rtl .info-content li {
  text-align: right;
}

.rtl .faq-question {
  text-align: right;
}

.rtl .faq-icon {
  order: -1;
}

.rtl .full-gratuity {
  flex-direction: row-reverse;
}

.rtl .service-summary {
  text-align: right;
}

@media (min-width: 768px) {
  .header {
    padding: 2.5rem 2rem;
  }

  .title {
    font-size: 2.25rem;
  }

  .subtitle {
    font-size: 1.1rem;
  }

  .main-content {
    padding: 2rem;
  }

  .input-section,
  .result-section,
  .info-section,
  .faq-section {
    padding: 2rem;
  }
}

.data-btn {
  padding: 0.5rem 1rem;
  background: rgba(255, 255, 255, 0.95);
  border: none;
  border-radius: 9999px;
  color: var(--primary-color);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 500;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-md);
}

.data-btn:hover {
  background: white;
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

.dashboard-container {
  min-height: 100vh;
  background: var(--bg-light);
}

.dashboard-header {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
  color: white;
  padding: 1.5rem 2rem;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.back-btn {
  padding: 0.6rem 1.25rem;
  background: rgba(255, 255, 255, 0.95);
  border: none;
  border-radius: 0.5rem;
  color: var(--primary-color);
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 500;
  transition: all 0.2s ease;
}

.back-btn:hover {
  background: white;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.dashboard-header h1 {
  font-size: 1.75rem;
  font-weight: 600;
}

.dashboard-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2.5rem 2rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
  margin-bottom: 2.5rem;
}

@media (min-width: 768px) {
  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(6, 1fr);
  }
}

.stat-card {
  background: white;
  border-radius: 1rem;
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.75rem;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-icon {
  font-size: 2.25rem;
}

.stat-info {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.stat-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
  font-weight: 500;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.pv-card {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.pv-card .stat-label,
.pv-card .stat-value {
  color: white;
}

.pv-card .stat-icon {
  filter: brightness(1.2);
}

.uv-card {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.uv-card .stat-label,
.uv-card .stat-value {
  color: white;
}

.uv-card .stat-icon {
  filter: brightness(1.2);
}

.total-amount-card {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
}

.total-amount-card .stat-label,
.total-amount-card .stat-value {
  color: white;
}

.total-amount-card .stat-icon {
  filter: brightness(1.2);
}

.tables-section {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 1024px) {
  .tables-section {
    grid-template-columns: 1fr 1fr;
  }
}

.data-table-section {
  background: white;
  border-radius: 1rem;
  padding: 2rem;
  box-shadow: var(--shadow-sm);
}

.data-table-section h2 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--border-color);
}

.table-container {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table th,
.data-table td {
  padding: 0.875rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.data-table th {
  font-weight: 600;
  color: var(--text-primary);
  background: var(--bg-light);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

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

.data-table tr:hover {
  background: var(--bg-light);
}

.data-table td {
  color: var(--text-secondary);
}

.uuid-cell {
  font-family: 'Courier New', monospace;
  font-size: 0.75rem;
  color: var(--primary-color);
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.no-data {
  text-align: center;
  color: var(--text-secondary);
  padding: 3rem;
  background: var(--bg-light);
  border-radius: 0.5rem;
}

.loading,
.error {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 50vh;
  font-size: 1.2rem;
}

.error {
  color: #DC2626;
}

@media (max-width: 480px) {
  html {
    font-size: 14px;
  }

  .header {
    padding: 1rem 0.75rem;
  }

  .title {
    font-size: 1.25rem;
  }

  .subtitle {
    font-size: 0.8rem;
  }

  .main-content {
    padding: 1rem 0.75rem;
  }

  .input-section,
  .result-section,
  .info-section,
  .faq-section {
    padding: 1rem;
  }

  .amount-value {
    font-size: 2rem;
  }

  .form-row,
  .form-row.date-row,
  .form-row.manual-row {
    flex-wrap: wrap;
    gap: 1rem;
  }

  .form-row .form-group {
    min-width: 100%;
  }

  .breakdown-header {
    flex-direction: column;
    gap: 0.25rem;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-content {
    padding: 1rem;
  }

  .dashboard-header {
    padding: 1rem;
  }

  .dashboard-header h1 {
    font-size: 1.25rem;
  }
}
