/* CSS Custom Properties (Variables) */
:root {
    --primary-blue: #3498db;
    --primary-dark-blue: #2980b9;
    --primary-green: #27ae60;
    --primary-dark-green: #229954;
    --primary-red: #e74c3c;
    --primary-dark-red: #c0392b;
    --text-dark: #2c3e50;
    --text-light: #7f8c8d;
    --bg-light: #f8f9fa;
    --bg-white: #ffffff;
    --border-light: #ecf0f1;
    --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 5px 15px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 5px 20px rgba(0, 0, 0, 0.1);
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
}

html, body {
    height: auto;
    min-height: 100%;
    overflow-y: auto;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

/* Skip Link */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary-blue);
    color: white;
    padding: 8px 16px;
    text-decoration: none;
    border-radius: 0 0 4px 0;
    z-index: 100;
    font-weight: bold;
}
.skip-link:focus {
    top: 0;
}

/* Focus Styles */
*:focus-visible {
    outline: 3px solid var(--primary-blue);
    outline-offset: 2px;
}
button:focus-visible,
select:focus-visible,
input:focus-visible {
    outline: 3px solid var(--primary-blue);
    outline-offset: 2px;
}

/* World Bank Header */
.world-bank-header {
    background: white;
    color: var(--text-dark);
    padding: 0 20px 5px 20px;
    margin-bottom: 0;
    box-shadow: var(--shadow-sm);
    transform-origin: top;
}

/* Header dropdown animation (optional) */
@keyframes slideDown {
    0% { transform: translateY(-100%); opacity: 0; }
    50% { opacity: 0.5; }
    100% { transform: translateY(0); opacity: 1; }
}

/* Logos container – desktop: 3 logos + text */
.header-logos-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 100%;
    margin: 0;
    padding: 5px 20px;
    gap: 25px;
    min-height: 50px;
}

/* Side logos */
.logo-left,
.logo-right {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
}

.logo-left img,
.logo-right img {
    max-height: 220px;
    width: auto;
    object-fit: contain;
    animation: fadeInScale 1.5s ease-out 0.3s both;
}

@keyframes fadeInScale {
    0% { opacity: 0; transform: scale(0.8); }
    100% { opacity: 1; transform: scale(1); }
}

.logo-right {
    text-align: right;
    justify-content: flex-end;
    margin-right: -15px;
}

/* Center content – desktop: World Bank logo + title stacked */
.header-center {
    flex: 1;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 0 50px;
    margin-top: -10px;
    gap: 0;
}

/* World Bank logo */
.wb-logo-container {
    margin-bottom: 0;
    margin-top: -15px;
}

.wb-logo-container img {
    max-height: 160px;
    max-width: 300px;
    object-fit: contain;
    background-color: transparent;
    padding: 0;
    border-radius: 0;
    display: block;
    margin: 0;
    animation: fadeInScale 1.5s ease-out 0.3s both;
}

/* Title */
.world-bank-title {
    font-size: 52px;
    margin: -8px 0 0 0;
    padding: 0;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
    font-weight: bold;
    line-height: 1.1;
    color: #0e0202;
}

/* Extra keyframe (kept for future use) */
@keyframes fadeInUp {
    0% { opacity: 0; transform: translateY(20px); }
    100% { opacity: 1; transform: translateY(0); }
}

.world-bank-subtitle {
    font-size: 30px;
    margin: 0 0 8px 0;
    color: #34495e;
    font-weight: 500;
}

.partnership-text {
    font-size: 13px;
    margin: 0;
    padding-top: 3px;
    color: #010e24;
    font-style: italic;
}

/* Old white header hidden */
.header { display: none; }

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
}

.header img {
    height: 80px;
    width: auto;
    max-width: 120px;
    object-fit: contain;
}

.header-title {
    text-align: center;
    flex: 1;
    margin: 0 20px;
}

.header h1 {
    color: var(--text-dark);
    font-size: 1.8rem;
    margin-bottom: 10px;
    line-height: 1.2;
}

.header p {
    color: var(--text-light);
    font-size: 1rem;
}

/* Main title */
.main-title {
    text-align: center;
    padding: 30px 0;
    color: white;
}

@keyframes fadeIn {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

.main-title h1,
.main-title h2 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Tabs */
.tab-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px 15px 0 0;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.tab {
    display: flex;
    background: #91b1f9;
}

.tab button {
    flex: 1;
    background: inherit;
    border: none;
    padding: 15px 20px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    color: var(--text-dark);
    transition: all var(--transition-normal);
}

.tab button:hover {
    background: #cff3fc;
    transform: translateY(-2px);
}

.tab button.active {
    background: #b2e5f1;
    color: #1976d2;
}

/* Tab content */
.tabcontent {
    display: none;
    background: white;
    padding: 30px;
    border-radius: 0 0 15px 15px;
    box-shadow: var(--shadow-lg);
}

.tabcontent.active {
    display: block;
}

/* Input and results sections */
.input-section {
    background: var(--bg-light);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 30px;
}

.results-section {
    background: var(--bg-light);
    border-radius: 10px;
    padding: 20px;
    margin-top: 30px;
}

.input-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-dark);
}

select,
input[type="number"] {
    width: 100%;
    max-width: 300px;
    padding: 12px;
    border: 2px solid var(--border-light);
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 15px;
    transition: border-color var(--transition-normal);
}

select:focus,
input[type="number"]:focus {
    border-color: var(--primary-blue);
    outline: none;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

/* Special input styles */
.auto-calculated {
    background-color: #e8f5e8 !important;
    border-color: #4caf50 !important;
    font-weight: bold;
}

.location-updated {
    background-color: #e3f2fd !important;
    border-color: #2196f3 !important;
    font-weight: bold;
}

/* Buttons */
.button-container {
    text-align: center;
    margin: 30px 0;
}

button {
    background: linear-gradient(135deg, var(--primary-blue), var(--primary-dark-blue));
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    margin: 5px;
    transition: all var(--transition-normal);
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.3);
}

button:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(52, 152, 219, 0.4);
}

button:active {
    transform: translateY(-1px);
}

.btn-clear {
    background: linear-gradient(135deg, var(--primary-red), var(--primary-dark-red));
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.3);
}

.btn-clear:hover {
    box-shadow: 0 6px 20px rgba(231, 76, 60, 0.4);
}

/* Results table */
.results-title {
    text-align: center;
    color: var(--text-dark);
    margin-bottom: 20px;
    font-size: 1.5rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

th,
td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
}

th {
    background: linear-gradient(135deg, var(--primary-blue), var(--primary-dark-blue));
    color: white;
    font-weight: 600;
}

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

/* Kc Reference Table */
.kc-reference-section {
    margin-top: 40px;
}

#kc-reference-table {
    font-size: 14px;
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

#kc-reference-table th {
    background: linear-gradient(135deg, var(--primary-blue), var(--primary-dark-blue));
    color: white;
    font-weight: 600;
    padding: 10px 20px;
    text-align: center;
    min-width: 80px;
}

#kc-reference-table th:first-child {
    min-width: 60px;
}

#kc-reference-table th:nth-child(2) {
    min-width: 200px;
    text-align: left;
}

#kc-reference-table th:last-child {
    background: linear-gradient(135deg, var(--primary-green), var(--primary-dark-green));
}

#kc-reference-table td {
    padding: 10px;
    text-align: center;
    border-bottom: 1px solid var(--border-light);
}

#kc-reference-table td:nth-child(2) {
    text-align: left;
    font-weight: 500;
}

#kc-reference-table tbody tr:hover {
    background: var(--bg-light);
    transition: background var(--transition-fast);
}

#kc-reference-table tbody tr:nth-child(even) {
    background: #f9f9f9;
}

#kc-reference-table tbody tr:nth-child(even):hover {
    background: #f0f0f0;
}

#kc-reference-table td:last-child {
    background: #d4edda !important;
    font-weight: bold;
    color: #155724;
}

#kc-reference-table tbody tr:hover td:last-child {
    background: #c3e6cb !important;
}

/* Footer */
.footer {
    background: rgba(44, 62, 80, 0.9);
    color: white;
    margin-top: 50px;
    padding: 30px 0;
}

.footer-tab {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.footer button {
    background: transparent;
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    margin: 5px;
}

.footer button:hover,
.footer button.active {
    background: rgba(255, 255, 255, 0.2);
    border-color: white;
}

.footercontent {
    display: none;
    text-align: center;
    padding: 20px;
    max-width: 800px;
    margin: 0 auto;
}

.footercontent.active {
    display: block;
}

/* Logo fallback */
.logo-placeholder {
    width: 80px;
    height: 80px;
    background: var(--primary-blue);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    font-weight: bold;
    font-size: 14px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    button:hover { transform: none; }
    .world-bank-header,
    .logo-left img,
    .logo-right img,
    .wb-logo-container img,
    .world-bank-title,
    .main-title,
    .container {
        animation: none !important;
    }
}

/* Print */
@media print {
    body {
        background: white;
        color: black;
    }
    .tab,
    .button-container,
    .footer,
    .skip-link {
        display: none;
    }
    .tabcontent {
        display: block !important;
        box-shadow: none;
        page-break-inside: avoid;
    }
    table { page-break-inside: avoid; }
    button { display: none; }
}
.principal-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr); /* equal-width columns */
  column-gap: 40px;                      /* horizontal space between columns */
  row-gap: 4px;                          /* vertical space between rows */
  justify-items: center;                 /* center each name in its cell */
  text-align: center;
}

.principal-line {
  text-align: center;
  margin: 6px 0 4px;
  word-spacing: 4px;
}


/* ==== MOBILE ONLY (≤ 768px) ==== */
@media (max-width: 768px) {
    

  /* Header: same layout, smaller */
  .world-bank-header {
    padding: 4px 8px;
  }

  .header-logos-container {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 0 6px;
  }

  .logo-left,
  .logo-right {
    flex: 0 0 auto;
    justify-content: center;
    margin-right: 0;
  }

  .logo-left img,
  .logo-right img {
    max-height: 50px;
  }

  .wb-logo-container img {
    max-height: 40px;
    max-width: 90px;
  }

  .header-center {
    flex: 0 1 auto;
    flex-direction: column;  /* WB logo above text */
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    gap: 2px;
    text-align: center;
    margin-top: 0;
  }

  /* Main context text smaller */
  .world-bank-title {
    font-size: 16px;
    line-height: 1.15;
    margin: 4px 0;
  }

  .world-bank-subtitle {
    font-size: 13px;
    margin: 0;
  }

  .partnership-text {
    font-size: 10px;
    margin: 0;
    padding-top: 2px;
  }

  /* Calculator title smaller */
  .main-title h1,
  .main-title h2 {
    font-size: 20px;
  }

  /* Content layout tweaks */
  body {
    font-size: 14px;
  }

  .container {
    padding: 10px;
  }

  .tab {
    flex-direction: column;
  }

  .tab button {
    width: 100%;
    border-radius: 0;
    font-size: 14px;
    padding: 10px 14px;
  }

  .input-section,
  .results-section {
    width: 100%;
    margin: 10px 0;
    padding: 15px;
  }

  .results-section table,
  #kc-reference-table {
    display: block;
    width: 100%;
    overflow-x: auto;
  }

  table {
    font-size: 12px;
  }

  th,
  td {
    padding: 8px;
    white-space: nowrap;
  }

  #kc-reference-table {
    font-size: 12px;
  }

  .button-container button,
  #goto-crop-btn-container button,
  .btn-clear {
    width: 100%;
    max-width: 100%;
    padding: 12px 18px;
    font-size: 15px;
    border-radius: 20px;
  }
}

/* Extra small phones (≤ 480px) */
@media (max-width: 480px) {
  .logo-left img,
  .logo-right img {
    max-height: 45px;
  }

  .wb-logo-container img {
    max-height: 36px;
  }

  .world-bank-title {
    font-size: 14px;
  }

  .main-title h1,
  .main-title h2 {
    font-size: 18px;
  }
}

