/* public/style.css */
/* ========================
   CSS RESET & VARIABLES
======================== */
:root {
  --bg-main: linear-gradient(135deg, #667eea, #764ba2);
  --card-bg: #ffffff;
  --text-main: #2c3e50;
  --text-muted: #777;
  --accent: #3498db;
  --success: #27ae60;
  --danger: #e74c3c;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 4px 10px rgba(0,0,0,0.08);
  --shadow-md: 0 8px 20px rgba(0,0,0,0.12);
  --transition: 0.25s ease;
  --font-base: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

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

/* ========================
   BASE
======================== */
html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-base);
  background: var(--bg-main);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  direction: rtl;
  text-align: right;
}

/* Touch-friendly */
button,
select,
input {
  min-height: 44px;
  touch-action: manipulation;
  font-family: inherit;
}

/* ========================
   HEADER
======================== */
header {
  background: rgba(255,255,255,0.12);
  color: #fff;
  padding: 18px 14px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

header h1 {
  margin: 0;
  font-size: 1.8rem;
  font-weight: 700;
}

header p {
  margin: 6px 0 0;
  font-size: 1rem;
  opacity: 0.9;
}

/* ========================
   MAIN CONTAINER
======================== */
main {
  max-width: 100%;
  margin: 16px 10px;
  padding: 18px;
  background: rgba(255,255,255,0.96);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

/* ========================
   SECTIONS
======================== */
section {
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(0,0,0,0.08);
}

section:last-of-type {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

h2 {
  margin-bottom: 18px;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-main);
  border-bottom: 3px solid var(--accent);
  display: inline-block;
  padding-bottom: 6px;
}

/* ========================
   PRICES GRID
======================== */
#prices-container {
    display: flex;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 14px;
    flex-direction: column;
}

.metal-card {
  background: var(--card-bg);
  padding: 16px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  text-align: center;
  transition: transform var(--transition), box-shadow var(--transition);
  border-top: 4px solid var(--metal-color, var(--accent));
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

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

.metal-card h3 {
  margin: 0 0 10px;
  font-size: 1.2rem;
  font-weight: 600;
}

.metal-card .current-display-price {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--success);
  margin: 10px 0;
}

/* Purity dropdowns */
.purity-control {
  margin-top: 8px;
}

.purity-control label {
  display: block;
  font-size: 0.85rem;
  margin-bottom: 4px;
  color: var(--text-muted);
}

.purity-control select {
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1.5px solid #ddd;
  font-size: 0.9rem;
}

.purity-control select:focus {
  outline: none;
  border-color: var(--accent);
}

/* ========================
   CALCULATOR
======================== */
.calculator-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 480px;
  margin: 0 auto;
  background: #fafafa;
  padding: 20px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.calculator-form label {
  font-weight: 600;
  font-size: 0.95rem;
}

.calculator-form select,
.calculator-form input[type="number"] {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid #ddd;
  font-size: 1rem;
}

.calculator-form select:focus,
.calculator-form input[type="number"]:focus {
  outline: none;
  border-color: var(--accent);
}

/* Button */
.calculator-form button {
  background: var(--bg-main);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  padding: 14px 18px;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition), opacity var(--transition);
}

.calculator-form button:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  opacity: 0.95;
}

.calculator-form button:active {
  transform: scale(0.98);
}

/* ========================
   RESULT BOX
======================== */
#calculation-result {
  margin-top: 18px;
  padding: 18px;
  background: var(--bg-main);
  color: #fff;
  border-radius: var(--radius-md);
  text-align: center;
  box-shadow: var(--shadow-md);
}

#calculation-result h3 {
  margin: 0 0 8px;
  font-size: 1.1rem;
  font-weight: 500;
}

#result-display {
  font-size: 2rem;
  font-weight: 700;
  word-break: break-word;
}

/* ========================
   HISTORY TABLE
======================== */
#history-section {
  overflow-x: auto;
  background: #fff;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 12px;
}

#history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  min-width: 280px;
}

#history-table th,
#history-table td {
  padding: 12px 10px;
  border-bottom: 1px solid rgba(0,0,0,0.08);
  text-align: right;
}

#history-table th {
  background: var(--bg-main);
  color: #fff;
  font-weight: 600;
  position: sticky;
  top: 0;
}

#history-table tr:hover td {
  background-color: rgba(52, 152, 219, 0.05);
}

#history-table tr:last-child td {
  border-bottom: none;
}

/* ========================
   CHART
======================== */
#chart-section {
  background: #fff;
  border-radius: var(--radius-md);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}

.chart-controls {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 14px;
}

.range-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.range-btn,
#reset-zoom-btn {
  padding: 10px 14px;
  background: #fff;
  border: 1.5px solid #ddd;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-main);
  transition: background var(--transition), color var(--transition), transform var(--transition);
}

.range-btn:hover,
#reset-zoom-btn:hover,
.range-btn.active {
  background: var(--bg-main);
  color: #fff;
  border-color: transparent;
  transform: translateY(-1px);
}

.toggles {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
}

#prices-chart {
  width: 100% !important;
  height: 320px !important;
  max-height: 60vh;
  margin: 0 auto;
  touch-action: pinch-zoom;
}

.no-data {
  text-align: center;
  color: var(--text-muted);
  padding: 30px 16px;
  font-style: italic;
}

/* ========================
   FOOTER
======================== */
footer {
  text-align: center;
  padding: 24px 16px;
  margin-top: 36px;
  background: rgba(255,255,255,0.12);
  color: #fff;
  font-size: 0.9rem;
}

footer a {
  color: #dce7ff;
  text-decoration: none;
  font-weight: 500;
}

footer a:hover {
  text-decoration: underline;
}

/* ========================
   STATES
======================== */
.loading-spinner {
  border: 4px solid rgba(0,0,0,0.1);
  border-top: 4px solid var(--accent);
  border-radius: 50%;
  width: 42px;
  height: 42px;
  animation: spin 1s linear infinite;
  margin: 30px auto;
}

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

.error {
  color: var(--danger);
  text-align: center;
  padding: 18px;
  background: rgba(231, 76, 60, 0.08);
  border-radius: var(--radius-md);
  border: 1.5px solid var(--danger);
  margin: 16px 0;
}

/* ========================
   METAL COLORS
======================== */
.metal-gold { --metal-color: #FFD700; }
.metal-silver { --metal-color: #C0C0C0; }
.metal-platinum { --metal-color: #E5E4E2; }
.metal-palladium { --metal-color: #C0C0C8; }
.metal-copper { --metal-color: #b87333; }
.metal-zinc { --metal-color: #7f8c8d; }
.metal-aluminum { --metal-color: #bdc3c7; }
.metal-nickel { --metal-color: #95a5a6; }
.metal-lead { --metal-color: #7f8c8d; }

/* ========================
   PRICE CHANGE FLASH
======================== */
.price-up {
  animation: flashGreen 1.5s ease;
}

.price-down {
  animation: flashRed 1.5s ease;
}

@keyframes flashGreen {
  0%, 100% { background-color: transparent; }
  50% { background-color: rgba(39, 174, 96, 0.12); }
}

@keyframes flashRed {
  0%, 100% { background-color: transparent; }
  50% { background-color: rgba(231, 76, 60, 0.12); }
}

/* ========================
   RESPONSIVE BREAKPOINTS
======================== */
@media (min-width: 768px) {
  body { font-size: 17px; }

  main {
    max-width: 760px;
    margin: 32px auto;
    padding: 30px;
  }

  header h1 { font-size: 2.2rem; }

  #prices-container {
    display: flex;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 14px;
    flex-direction: column;
}

  .calculator-form { max-width: 540px; }

  .chart-controls {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }

  #prices-chart { height: 380px !important; }
}

@media (min-width: 1024px) {
  main {
    max-width: 1000px;
    padding: 36px;
  }

    #prices-container {
    display: flex;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 14px;
    flex-direction: column;
}

  .calculator-form { max-width: 600px; }

  #prices-chart { height: 420px !important; }
}

/* ===== BANNER AD STYLES ===== */
.ad-container {
    margin: 20px auto 30px;
    text-align: center;
    background: #f4f7fb;
    border-radius: 12px;
    padding: 10px;
    min-height: 90px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.ad-container ins {
    display: block;
    margin: 0 auto;
}


.header-link {
    text-decoration: none; /* Remove underline from the link */
    color: inherit; /* Inherit text color from parent (header) */
    display: block; /* Make the entire area of the header clickable */
    cursor: pointer; /* Indicate it's clickable */
}

.header-link:hover {
    color: #a9c6e3; /* Example hover effect for the text */
}

.header-link h1 {
    margin-top: 0; /* Remove default top margin */
    margin-bottom: 5px; /* Adjust spacing */
    font-size: 2em; /* Example font size */
}

.header-link p {
    margin-top: 0; /* Remove default top margin */
    font-size: 1.1em; /* Example font size */
    color: #f9f523; /* Example color */
}