/* interest-rate.css - Dedicated Styles for Interest Rate Calculator */

:root {
  --ir-blue-dark: #244a75;
  --ir-blue-header: #0844a4;
  --ir-blue-btn: #1f5799;
  --ir-green-header: #5c8b29;
  --ir-green-hover: #4d7a1c;
  --ir-border: #cbd5e1;
  --ir-border-card: #c0c0c0;
  --ir-bg-card: #ffffff;
  --ir-text-dark: #222222;
  --ir-text-muted: #555555;
  --ir-link: #0844a4;
  --ir-chart-balance: #1e70bf;
  --ir-chart-interest: #5c8b29;
  --ir-chart-payment: #b71c1c;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--ir-text-dark);
  background-color: #ffffff;
  line-height: 1.5;
}

.ir-page-container {
  max-width: 1140px;
  margin: 0 auto;
  padding: 14px 16px 40px;
}

/* Breadcrumbs & Top Utilities */
.ir-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.ir-breadcrumbs {
  font-size: 13px;
  color: #666666;
}

.ir-breadcrumbs a {
  color: var(--ir-link);
  text-decoration: none;
}

.ir-breadcrumbs a:hover {
  text-decoration: underline;
}

.ir-breadcrumbs .sep {
  margin: 0 4px;
  color: #999999;
}

.ir-breadcrumbs .current {
  color: #333333;
  font-weight: 600;
}

.ir-top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ir-top-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #ffffff;
  border: 1px solid #c0c0c0;
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  color: #333333;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.ir-top-btn:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
}

.ir-top-btn svg {
  width: 13px;
  height: 13px;
  fill: currentColor;
}

.ir-badge {
  background: #e2e8f0;
  color: #1e293b;
  font-size: 11px;
  padding: 1px 5px;
  border-radius: 10px;
  font-weight: 600;
}

/* Page Title & Intro */
.ir-page-title {
  font-size: 26px;
  font-weight: 700;
  color: var(--ir-blue-header);
  margin: 0 0 10px 0;
  letter-spacing: -0.2px;
}

.ir-intro-text {
  font-size: 14px;
  color: #333333;
  line-height: 1.55;
  margin-bottom: 20px;
  max-width: 900px;
}

.ir-intro-text a {
  color: var(--ir-link);
  text-decoration: underline;
}

.ir-intro-text a:hover {
  color: #052c6e;
}

/* Main Layout: Left Main Column & Right Sidebar */
.ir-layout-grid {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 24px;
  align-items: start;
}

@media (max-width: 900px) {
  .ir-layout-grid {
    grid-template-columns: 1fr;
  }
}

.ir-main-col {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ==========================================================================
   Calculator Form & Results Side-by-Side (Matching Image 2)
   ========================================================================== */
.ir-calc-boxes {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 16px;
  align-items: stretch;
}

@media (max-width: 680px) {
  .ir-calc-boxes {
    grid-template-columns: 1fr;
  }
}

/* Input Form Card */
.ir-form-card {
  border: 1px solid var(--ir-border-card);
  background: #fdfdfd;
  padding: 16px;
  border-radius: 2px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.ir-form-table {
  width: 100%;
  border-collapse: collapse;
}

.ir-form-table td {
  padding: 6px 0;
  vertical-align: middle;
}

.ir-form-table td:first-child {
  width: 42%;
  font-size: 13.5px;
  color: #222222;
  font-weight: 500;
}

.ir-form-table td:last-child {
  width: 58%;
}

.ir-input-group {
  display: flex;
  align-items: center;
  border: 1px solid #4a7bb0;
  background: #ffffff;
  border-radius: 2px;
  padding: 0 4px;
  height: 28px;
  width: 100%;
  max-width: 180px;
}

.ir-input-group .curr-symbol {
  font-size: 13px;
  color: #333333;
  margin-right: 3px;
  user-select: none;
}

.ir-input {
  border: none;
  outline: none;
  font-size: 13.5px;
  color: #111111;
  width: 100%;
  background: transparent;
  padding: 0 2px;
  font-family: inherit;
}

.ir-input:focus {
  outline: none;
}

/* Term inputs: [ 3 ] years [ 0 ] months */
.ir-term-group {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  color: #444444;
}

.ir-term-group input {
  width: 44px;
  height: 28px;
  border: 1px solid #4a7bb0;
  background: #ffffff;
  border-radius: 2px;
  text-align: center;
  font-size: 13.5px;
  font-family: inherit;
}

.ir-term-group input:focus {
  outline: 1px solid #1f5799;
}

.ir-term-label {
  user-select: none;
}

/* Button Row */
.ir-btn-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}

.ir-btn-calc {
  background: linear-gradient(to bottom, #699b31, #538124);
  border: 1px solid #456d1c;
  color: #ffffff;
  font-size: 13px;
  font-weight: bold;
  padding: 5px 16px;
  border-radius: 3px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}

.ir-btn-calc:hover {
  background: linear-gradient(to bottom, #5f8d2b, #48731e);
}

.ir-btn-calc:active {
  background: #48731e;
}

.ir-btn-calc svg {
  width: 12px;
  height: 12px;
  fill: #ffffff;
}

.ir-btn-clear {
  background: linear-gradient(to bottom, #f0f0f0, #dcdcdc);
  border: 1px solid #b8b8b8;
  color: #333333;
  font-size: 13px;
  font-weight: 500;
  padding: 5px 14px;
  border-radius: 3px;
  cursor: pointer;
}

.ir-btn-clear:hover {
  background: linear-gradient(to bottom, #e4e4e4, #cecece);
}

/* Results Card (Matching Image 2) */
.ir-results-card {
  border: 1px solid var(--ir-border-card);
  background: #ffffff;
  border-radius: 2px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ir-results-header {
  background: var(--ir-green-header);
  color: #ffffff;
  padding: 6px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: bold;
  font-size: 14px;
}

.ir-results-header .save-icon-btn {
  background: transparent;
  border: none;
  color: #ffffff;
  cursor: pointer;
  padding: 2px;
  display: flex;
  align-items: center;
  opacity: 0.9;
  transition: opacity 0.15s;
}

.ir-results-header .save-icon-btn:hover {
  opacity: 1;
  transform: scale(1.1);
}

.ir-results-header .save-icon-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.ir-results-body {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  justify-content: space-around;
}

.ir-result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13.5px;
  color: #222222;
}

.ir-result-label {
  font-weight: 500;
  color: #222222;
}

.ir-rate-badge {
  background: #e8e8e8;
  border: 1px solid #d4d4d4;
  font-size: 14px;
  font-weight: 700;
  color: #111111;
  padding: 3px 12px;
  border-radius: 2px;
  min-width: 75px;
  text-align: right;
}

.ir-result-val {
  font-weight: 600;
  color: #111111;
}

/* ==========================================================================
   Graphs Row (Amortization Graph & Donut Breakdown matching Image 2)
   ========================================================================== */
.ir-graphs-row {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 16px;
  margin-top: 5px;
}

@media (max-width: 680px) {
  .ir-graphs-row {
    grid-template-columns: 1fr;
  }
}

.ir-graph-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.ir-graph-heading {
  font-size: 15px;
  font-weight: bold;
  color: #111111;
  margin-bottom: 8px;
  text-align: center;
}

.ir-svg-wrap {
  width: 100%;
  background: #ffffff;
  border: 1px solid #e0e0e0;
  border-radius: 2px;
  position: relative;
  overflow: hidden;
}

.ir-svg-chart {
  display: block;
  width: 100%;
  height: auto;
}

/* Chart Tooltip */
.ir-chart-tooltip {
  position: absolute;
  background: rgba(15, 23, 42, 0.92);
  color: #ffffff;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 11.5px;
  pointer-events: none;
  z-index: 20;
  box-shadow: 0 4px 6px rgba(0,0,0,0.2);
  display: none;
  white-space: nowrap;
}

/* ==========================================================================
   Right Sidebar (Matching Image 2)
   ========================================================================== */
.ir-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.ir-search-box {
  display: flex;
  width: 100%;
  gap: 0;
  position: relative;
}

.ir-search-input {
  flex: 1;
  border: 1px solid #244a75;
  border-right: none;
  height: 30px;
  padding: 0 8px;
  font-size: 13px;
  outline: none;
  border-radius: 2px 0 0 2px;
  font-family: inherit;
}

.ir-search-btn {
  background: #1f5799;
  color: #ffffff;
  border: 1px solid #1f5799;
  border-radius: 0 2px 2px 0;
  font-size: 13px;
  font-weight: 500;
  padding: 0 12px;
  cursor: pointer;
  height: 30px;
}

.ir-search-btn:hover {
  background: #17457a;
}

.ir-search-dropdown {
  position: absolute;
  top: 32px;
  left: 0;
  right: 0;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  box-shadow: 0 8px 16px rgba(0,0,0,0.15);
  border-radius: 4px;
  max-height: 280px;
  overflow-y: auto;
  z-index: 100;
  display: none;
}

.ir-search-item {
  padding: 8px 12px;
  font-size: 12.5px;
  cursor: pointer;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ir-search-item:hover, .ir-search-item.highlighted {
  background: #f1f5f9;
}

.ir-search-item .item-cat {
  font-size: 11px;
  color: #64748b;
  background: #e2e8f0;
  padding: 1px 6px;
  border-radius: 8px;
}

/* Sidebar Financial Calculators List */
.ir-side-card {
  border: 1px solid #244a75;
  border-radius: 2px;
  overflow: hidden;
  background: #ffffff;
}

.ir-side-card-header {
  background: #244a75;
  color: #ffffff;
  font-size: 14px;
  font-weight: bold;
  padding: 7px 12px;
}

.ir-side-card-body {
  padding: 10px 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 12px;
  row-gap: 6px;
}

.ir-side-link {
  font-size: 12.5px;
  color: var(--ir-link);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ir-side-link:hover {
  text-decoration: underline;
}

.ir-side-link.active {
  font-weight: bold;
  color: #000000;
}

.ir-side-card-more {
  border-top: 1px solid #e0e0e0;
  padding: 6px 12px;
  font-size: 12px;
}

.ir-side-card-more a {
  color: var(--ir-link);
  text-decoration: none;
}

.ir-side-card-more a:hover {
  text-decoration: underline;
}

.ir-side-card-footer {
  border-top: 1px solid #e0e0e0;
  background: #f5f5f5;
  padding: 6px 10px;
  font-size: 11.5px;
  color: #666666;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.ir-side-card-footer a {
  color: var(--ir-link);
  text-decoration: underline;
}

.ir-side-card-footer .active-cat {
  color: #333333;
  text-decoration: none;
  font-weight: bold;
}

/* ==========================================================================
   Amortization Schedule Section
   ========================================================================== */
.ir-schedule-section {
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  background: #ffffff;
  padding: 16px;
  margin-top: 10px;
}

.ir-schedule-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.ir-sec-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--ir-blue-dark);
  margin: 0;
}

.ir-tabs {
  display: inline-flex;
  border: 1px solid #cbd5e1;
  border-radius: 3px;
  overflow: hidden;
}

.ir-tab-btn {
  background: #f8fafc;
  border: none;
  padding: 4px 12px;
  font-size: 12.5px;
  font-weight: 500;
  color: #475569;
  cursor: pointer;
  border-right: 1px solid #cbd5e1;
}

.ir-tab-btn:last-child {
  border-right: none;
}

.ir-tab-btn.active {
  background: #244a75;
  color: #ffffff;
}

.ir-table-wrap {
  max-height: 380px;
  overflow-y: auto;
  border: 1px solid #e2e8f0;
  border-radius: 3px;
}

.ir-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.ir-table th {
  background: #f1f5f9;
  position: sticky;
  top: 0;
  z-index: 2;
  text-align: right;
  padding: 7px 10px;
  font-weight: 600;
  color: #334155;
  border-bottom: 1px solid #cbd5e1;
}

.ir-table th:first-child, .ir-table td:first-child {
  text-align: center;
}

.ir-table td {
  padding: 6px 10px;
  text-align: right;
  border-bottom: 1px solid #f1f5f9;
}

.ir-table tbody tr:nth-child(even) {
  background: #f8fafc;
}

.ir-table tbody tr:hover {
  background: #eff6ff;
}

/* ==========================================================================
   Fraction Arithmetic Section (Core Requirement 1 & 5)
   ========================================================================== */
.ir-fraction-section {
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  background: #fcfcfc;
  padding: 18px;
  margin-top: 10px;
}

.ir-fraction-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 14px;
}

@media (max-width: 768px) {
  .ir-fraction-grid {
    grid-template-columns: 1fr;
  }
}

.ir-fraction-calc-box {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 16px;
}

.ir-fraction-inputs-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin: 14px 0;
}

.ir-fraction-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 60px;
}

.ir-fraction-col input {
  width: 54px;
  height: 30px;
  border: 1px solid #4a7bb0;
  border-radius: 2px;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
}

.ir-fraction-bar {
  width: 54px;
  height: 2px;
  background: #333333;
  margin: 4px 0;
}

.ir-fraction-op-select {
  height: 32px;
  font-size: 15px;
  font-weight: bold;
  border: 1px solid #4a7bb0;
  border-radius: 2px;
  padding: 0 6px;
  background: #ffffff;
}

.ir-fraction-results-box {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ir-frac-val-highlight {
  font-size: 18px;
  font-weight: 700;
  color: var(--ir-blue-header);
}

.ir-step-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 3px;
  padding: 8px 12px;
  font-family: monospace;
  font-size: 12.5px;
  color: #1e293b;
  margin-top: 6px;
  white-space: pre-wrap;
}

/* Fraction Visualizations */
.ir-fraction-visuals-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 14px;
}

@media (max-width: 800px) {
  .ir-fraction-visuals-grid {
    grid-template-columns: 1fr;
  }
}

.ir-vis-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 12px;
  text-align: center;
}

.ir-vis-title {
  font-size: 13px;
  font-weight: 600;
  color: #334155;
  margin-bottom: 8px;
}

/* ==========================================================================
   Modals (Image 1 Instant Tool, Saved Scenarios, Print Report)
   ========================================================================== */
.ir-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 16px;
}

.ir-modal-dialog {
  background: #ffffff;
  border-radius: 3px;
  max-width: 520px;
  width: 100%;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  animation: irFadeIn 0.15s ease-out;
}

.ir-modal-dialog-lg {
  max-width: 780px;
}

@keyframes irFadeIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Image 1 Header: Blue bar with white title and 'x' */
.ir-modal-header {
  background: var(--ir-blue-dark);
  color: #ffffff;
  padding: 10px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ir-modal-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.ir-modal-close-icon {
  background: none;
  border: none;
  color: #ffffff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.85;
}

.ir-modal-close-icon:hover {
  opacity: 1;
}

.ir-modal-body {
  padding: 16px;
  max-height: 80vh;
  overflow-y: auto;
}

.ir-modal-subtitle {
  font-size: 13.5px;
  color: #444444;
  margin-bottom: 16px;
}

.ir-instant-field {
  margin-bottom: 14px;
}

.ir-instant-field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #222222;
  margin-bottom: 4px;
}

.ir-instant-field input {
  width: 100%;
  height: 32px;
  border: 1px solid #4a7bb0;
  border-radius: 2px;
  padding: 0 8px;
  font-size: 14px;
  font-family: inherit;
}

.ir-instant-btn {
  background: var(--ir-blue-dark);
  color: #ffffff;
  border: 1px solid #1a3656;
  border-radius: 3px;
  padding: 8px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  margin-top: 10px;
}

.ir-instant-btn:hover {
  background: #1a375a;
}

.ir-instant-results {
  margin-top: 16px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 3px;
  padding: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  font-size: 13px;
}

/* Print Toolbar */
.ir-print-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  background: #f1f5f9;
  padding: 8px;
  border-radius: 4px;
}

.ir-print-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 3px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
}

.ir-print-action-btn:hover {
  background: #f8fafc;
  border-color: #94a3b8;
}

.ir-print-action-btn.primary {
  background: #244a75;
  color: #ffffff;
  border-color: #1a3656;
}

/* Toast */
.ir-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1e293b;
  color: #ffffff;
  padding: 10px 18px;
  border-radius: 4px;
  font-size: 13px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 10000;
  display: none;
  animation: irToastFade 0.2s ease-in-out;
}

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

/* RTL Support for Arabic */
[dir="rtl"] {
  text-align: right;
}

[dir="rtl"] .ir-form-table td:first-child {
  text-align: right;
}

[dir="rtl"] .ir-input-group .curr-symbol {
  margin-right: 0;
  margin-left: 3px;
}

[dir="rtl"] .ir-search-input {
  border-right: 1px solid #244a75;
  border-left: none;
  border-radius: 0 2px 2px 0;
}

[dir="rtl"] .ir-search-btn {
  border-radius: 2px 0 0 2px;
}

/* Print Sheet Styling */
@media print {
  .site-header, .ir-top-actions, .ir-sidebar, .ir-btn-row, #lang-switcher-ui, .site-footer {
    display: none !important;
  }
  .ir-layout-grid {
    grid-template-columns: 1fr !important;
  }
  .ir-page-container {
    max-width: 100% !important;
    padding: 0 !important;
  }
}
