/* ===================================================================
   ENHANCED STYLE V3: Developer Guru Edition + SEO & Share Features
   =================================================================== */

/*--------------------------------------------------------------
1. Enhanced Variables & Theme
--------------------------------------------------------------*/
:root {
  --primary-color: #000091;
  --secondary-color: #E1000F;
  --success-color: #00A95F;
  --warning-color: #FF8500;
  --info-color: #0078D4;
  --danger-color: #DC3545;
  --bg-light: #f6f7fb;
  --bg-card: #ffffff;
  --text-dark: #1e293b;
  --text-muted: #64748b;
  --text-light: #fff;
  --border-color: #e2e8f0;
  --font-heading: 'Poppins', sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --shadow-sm: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-md: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.08);
  --shadow-lg: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
  --border-radius: 0.75rem;
  --transition-speed: 0.3s;
  --gradient-primary: linear-gradient(135deg, var(--primary-color) 0%, #0077CC 100%);
  --gradient-secondary: linear-gradient(135deg, var(--secondary-color) 0%, #FF4444 100%);
}

/* Dark mode support */
body.dark-theme {
    --bg-light: #0f172a;
    --bg-card: #1e293b;
    --text-dark: #f1f5f9;
    --text-muted: #cbd5e1;
    --border-color: #334155;
}

/*--------------------------------------------------------------
2. Enhanced Reset & Base Styles
--------------------------------------------------------------*/
*, *::before, *::after { 
  box-sizing: border-box; 
  margin: 0; 
  padding: 0; 
}

html { 
  scroll-behavior: smooth; 
  font-size: 16px;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-light);
  color: var(--text-dark);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  transition: background-color var(--transition-speed) ease, color var(--transition-speed) ease;
}

a:focus-visible, button:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

.container { 
  max-width: 1400px; 
  margin: 0 auto; 
  padding: 0 2rem; 
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border-width: 0;
}

/*--------------------------------------------------------------
3. Enhanced Navigation + New Buttons
--------------------------------------------------------------*/
.nav-container {
  position: fixed; top: 0; left: 0; width: 100%;
  background-color: rgba(255, 255, 255, 0.9);
  z-index: 1000; backdrop-filter: blur(12px);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-speed) ease;
}

body.dark-theme .nav-container {
    background-color: rgba(15, 23, 42, 0.9);
}

.nav-container.scrolled {
  box-shadow: var(--shadow-md);
}

.navbar {
  display: flex; justify-content: space-between; align-items: center;
  height: 70px;
}

.logo {
  color: var(--primary-color); font-weight: 700;
  font-family: var(--font-heading); font-size: 1.5rem; text-decoration: none;
  display: flex; align-items: center; gap: 8px;
}

.nav-links {
  display: flex; list-style: none; gap: 32px;
}

.nav-links a {
  color: var(--text-dark); text-decoration: none; font-weight: 500;
  font-size: 0.95rem; transition: color var(--transition-speed) ease;
  position: relative; padding: 8px 0;
}

.nav-links a::after {
  content: ''; position: absolute; bottom: 0; left: 0;
  width: 0; height: 2px; background-color: var(--secondary-color);
  transition: width var(--transition-speed) ease;
}

.nav-links a:hover, .nav-links a.active { 
  color: var(--primary-color); 
}

.nav-links a:hover::after, .nav-links a.active::after { 
  width: 100%; 
}

/* Enhanced buttons for navigation */
.theme-toggle, .share-btn, .github-btn {
  background: none;
  border: none;
  font-size: 1.2rem;
  color: var(--text-dark);
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  transition: all var(--transition-speed) ease;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
}

.theme-toggle:hover, .share-btn:hover, .github-btn:hover {
  background-color: var(--bg-light);
  transform: scale(1.1);
}

.github-btn {
  color: var(--primary-color);
}

.share-btn:hover {
  color: var(--secondary-color);
}

.theme-toggle:hover {
  transform: rotate(15deg) scale(1.1);
}

.mobile-menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.2rem;
  color: var(--text-dark);
  cursor: pointer;
  padding: 8px;
}

/*--------------------------------------------------------------
4. Share Modal Styles
--------------------------------------------------------------*/
.share-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  backdrop-filter: blur(4px);
}

.share-modal-content {
  background: var(--bg-card);
  border-radius: var(--border-radius);
  padding: 2rem;
  max-width: 500px;
  width: 90%;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from { transform: translateY(-20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.share-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.share-header h3 {
  margin: 0;
  color: var(--primary-color);
  font-family: var(--font-heading);
  font-weight: 600;
}

.share-close {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  border-radius: 4px;
  transition: all var(--transition-speed) ease;
}

.share-close:hover {
  color: var(--text-dark);
  background: var(--bg-light);
}

.share-url {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.share-url input {
  flex: 1;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  font-size: 0.9rem;
  background: var(--bg-light);
  color: var(--text-dark);
  font-family: var(--font-body);
}

.copy-btn {
  padding: 0.75rem;
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all var(--transition-speed) ease;
  min-width: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.copy-btn:hover {
  background: #0056b3;
  transform: translateY(-1px);
}

.share-social {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 1rem;
}

.social-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  text-decoration: none;
  font-weight: 500;
  transition: all var(--transition-speed) ease;
  justify-content: center;
  font-size: 0.9rem;
}

.social-btn.twitter {
  background: #1DA1F2;
  color: white;
}

.social-btn.linkedin {
  background: #0077B5;
  color: white;
}

.social-btn.facebook {
  background: #1877F2;
  color: white;
}

.social-btn.telegram {
  background: #0088CC;
  color: white;
}

.social-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/*--------------------------------------------------------------
5. Enhanced Hero Section with Attribution
--------------------------------------------------------------*/
.hero {
  padding: 120px 2rem 140px; text-align: center;
  background: var(--gradient-primary);
  position: relative; overflow: hidden;
  color: var(--text-light);
}

.hero-content { 
  z-index: 2; max-width: 1000px; margin: 0 auto; position: relative;
}

.hero-kicker {
  font-weight: 500; color: rgba(255,255,255,0.8); margin-bottom: 10px;
  text-transform: uppercase; letter-spacing: 1px; font-size: 0.9rem;
}

.hero-title {
  font-family: var(--font-heading);
  font-size: clamp(3rem, 7vw, 5.5rem);
  font-weight: 800; color: var(--text-light); margin-bottom: 20px;
  text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.3);
}

.hero-subtitle {
  font-size: clamp(1rem, 2.5vw, 1.3rem); 
  color: rgba(255, 255, 255, 0.95);
  max-width: 800px; margin: 0 auto 30px;
}

.hero-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem; margin-top: 2rem; max-width: 800px; margin-left: auto; margin-right: auto;
}

.hero-stat {
  background: rgba(255, 255, 255, 0.1); backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2); border-radius: var(--border-radius);
  padding: 1.5rem 1rem; text-align: center; transition: transform var(--transition-speed) ease;
}
.hero-stat:hover { transform: translateY(-5px); }
.hero-stat-value { font-size: 2rem; font-weight: 700; color: var(--text-light); margin-bottom: 0.5rem; }
.hero-stat-label { font-size: 0.9rem; color: rgba(255, 255, 255, 0.8); text-transform: uppercase; }

.hero-badge {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px;
  border-radius: 999px; font-size: .9rem; color: var(--text-light);
  background: rgba(0,0,0,0.2); backdrop-filter: blur(4px);
  border: 1px solid rgba(255,255,255,0.3); margin-top: 1rem;
}

.hero-badge .dot { 
  width: 10px; height: 10px; border-radius: 50%; 
  background: var(--success-color); animation: pulse 2s infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* New Attribution Section */
.hero-attribution {
  margin-top: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 0.9rem;
}

.attribution-link {
  color: rgba(255, 255, 255, 0.9);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 2rem;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  transition: all var(--transition-speed) ease;
  font-weight: 500;
}

.attribution-link:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
  color: var(--text-light);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.attribution-link.github {
  background: rgba(255, 255, 255, 0.15);
}

.attribution-link.github:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: translateY(-2px) scale(1.02);
}

.attribution-link.aifr:hover {
  background: rgba(225, 0, 15, 0.2);
}

.attribution-link i {
  font-size: 1.1rem;
  opacity: 0.9;
}

.attribution-link.github i {
  font-size: 1.2rem;
}

.attribution-divider {
  color: rgba(255, 255, 255, 0.6);
  font-weight: 300;
}

.wave {
  position: absolute; bottom: -1px; left: 0; width: 100%; height: 100px;
}
.wave svg path {
    fill: var(--bg-light);
    transition: fill var(--transition-speed) ease;
}

/*--------------------------------------------------------------
6. Enhanced Dashboard Layout
--------------------------------------------------------------*/
main.dashboard { margin: -100px auto 4rem auto; z-index: 10; position: relative; }
.quick-actions {
  background: var(--bg-card); border-radius: var(--border-radius); padding: 1rem 1.5rem;
  margin-bottom: 2rem; box-shadow: var(--shadow-sm); display: flex;
  justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 1rem;
}
.time-selector { display: flex; gap: 0.5rem; }
.time-btn {
  padding: 0.5rem 1rem; border: 1px solid var(--primary-color); background: transparent;
  color: var(--primary-color); border-radius: 2rem; cursor: pointer;
  transition: all var(--transition-speed) ease; font-size: 0.85rem; font-weight: 500;
}
.time-btn.active, .time-btn:hover { background: var(--primary-color); color: var(--text-light); }
.export-actions { display: flex; gap: 0.5rem; }
.export-btn {
  padding: 0.5rem 1rem; border: none; background: var(--info-color); color: var(--text-light);
  border-radius: 0.5rem; cursor: pointer; transition: all var(--transition-speed) ease;
  font-size: 0.85rem; display: flex; align-items: center; gap: 0.5rem;
}
.export-btn:hover { background: #005a9e; transform: translateY(-2px); }

/*--------------------------------------------------------------
7. Enhanced Statistics Cards
--------------------------------------------------------------*/
.stats-container {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem; margin-bottom: 3rem;
}
.stat-card {
  background: var(--bg-card); border-radius: var(--border-radius); padding: 1.75rem;
  box-shadow: var(--shadow-sm); transition: all var(--transition-speed) ease;
  position: relative; overflow: hidden;
}
.stat-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: var(--gradient-primary);
}
.stat-card:hover { transform: translateY(-8px); box-shadow: var(--shadow-lg); }
.stat-card h3 {
  display: flex; align-items: center; gap: 0.75rem; font-size: 1rem;
  color: var(--primary-color); margin-bottom: 1rem; font-weight: 600;
  text-transform: uppercase;
}
.stat-value {
  font-family: var(--font-heading); font-size: 2.5rem; font-weight: 700;
  color: var(--text-dark); line-height: 1.1; margin-bottom: 0.5rem;
}
.stat-trend { display: flex; align-items: center; gap: 0.5rem; font-size: 0.9rem; margin-top: 0.5rem; }
.trend-up { color: var(--danger-color); }
.trend-down { color: var(--success-color); }
.stat-sub { font-size: .85rem; color: var(--text-muted); margin-top: 4px; }

/*--------------------------------------------------------------
8. Enhanced Charts Section & Data Table
--------------------------------------------------------------*/
.chart-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(450px, 100%), 1fr));
  gap: 1.5rem; margin-bottom: 3rem;
}
.chart-container {
  background: var(--bg-card); padding: 1.75rem; border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm); display: flex; flex-direction: column;
  transition: box-shadow var(--transition-speed) ease;
}
.chart-container:hover { box-shadow: var(--shadow-md); }
.chart-container h2 {
  font-size: 1.3rem; margin-bottom: 1.5rem; color: var(--primary-color);
  font-weight: 600; display: flex; align-items: center; gap: 0.75rem;
  font-family: var(--font-heading);
}
.chart-controls { display: flex; gap: 0.5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.chart-toggle {
  padding: 0.25rem 0.75rem; border: 1px solid var(--primary-color); background: transparent;
  color: var(--primary-color); border-radius: 1rem; cursor: pointer;
  transition: all var(--transition-speed) ease; font-size: 0.8rem;
}
.chart-toggle.active, .chart-toggle:hover { background: var(--primary-color); color: var(--text-light); }
.chart-box { flex-grow: 1; position: relative; min-height: 350px; }
.chart-note { font-size: .8rem; color: var(--text-muted); margin-top: 15px; }
.chart-full-width { grid-column: 1 / -1; }

.data-table-section { background: var(--bg-card); border-radius: var(--border-radius); padding: 2rem; margin: 2rem 0; box-shadow: var(--shadow-sm); overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; margin-top: 1rem; }
.data-table th, .data-table td { padding: 1rem; text-align: left; border-bottom: 1px solid var(--border-color); }
.data-table th { background-color: var(--bg-light); font-weight: 600; color: var(--primary-color); }
body:not(.dark-theme) .data-table tr:hover { background-color: #f8fafc; }
body.dark-theme .data-table tr:hover { background-color: #2c3a52; }
.data-table .number { text-align: right; font-family: var(--font-heading); font-weight: 500; }

/*--------------------------------------------------------------
9. Other Sections (Comparison, About)
--------------------------------------------------------------*/
.comparison-section { background: var(--bg-card); border-radius: var(--border-radius); padding: 2rem; margin: 2rem 0; box-shadow: var(--shadow-sm); }
.comparison-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1.5rem; margin-top: 1.5rem; }
.country-card {
  padding: 1.5rem; border: 1px solid var(--border-color); border-radius: var(--border-radius);
  transition: all var(--transition-speed) ease; text-align: center;
}
.country-card:hover { border-color: var(--primary-color); transform: translateY(-3px); box-shadow: var(--shadow-md); }
.country-flag { font-size: 2rem; margin-bottom: 0.5rem; }
.country-name { font-weight: 600; margin-bottom: 0.5rem; color: var(--text-dark); }
.country-debt { font-size: 1.5rem; font-weight: 700; color: var(--primary-color); }
.country-rank { font-size: 0.8rem; color: var(--text-muted); }

/*--------------------------------------------------------------
10. Loading & Animations
--------------------------------------------------------------*/
.fade-in-up { opacity: 0; transform: translateY(30px); animation: fadeInUp 0.8s ease-out forwards; }
@keyframes fadeInUp { to { opacity: 1; transform: translateY(0); } }

.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%; animation: loading 1.5s infinite;
  border-radius: 6px; color: transparent !important; user-select: none;
}
body.dark-theme .skeleton { background: linear-gradient(90deg, #2c3a52 25%, #334155 50%, #2c3a52 75%); background-size: 200% 100%; }
@keyframes loading { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.loading-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: var(--bg-light); display: flex; align-items: center; justify-content: center;
  z-index: 9999; transition: opacity 0.3s ease;
}
.loading-spinner {
  width: 50px; height: 50px; border: 4px solid var(--border-color);
  border-top-color: var(--primary-color); border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/*--------------------------------------------------------------
11. Footer & FAB
--------------------------------------------------------------*/
.site-footer {
  background: #1e293b; color: #e2e8f0;
  padding: 4rem 0 2rem; margin-top: 4rem;
}
body.dark-theme .site-footer { background: #0b1120; }
.footer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 2rem; margin-bottom: 2rem; }
.footer-section h3 { color: var(--text-light); margin-bottom: 1rem; }
.footer-section ul { list-style: none; }
.footer-section li { margin-bottom: 0.5rem; }
.footer-section a { color: #cbd5e1; text-decoration: none; transition: color var(--transition-speed); }
.footer-section a:hover { color: var(--text-light); }
.footer-bottom { border-top: 1px solid #334155; padding-top: 2rem; text-align: center; color: var(--text-muted); }

.fab {
  position: fixed; bottom: 2rem; right: 2rem; width: 56px; height: 56px;
  border-radius: 50%; background: var(--primary-color); color: var(--text-light);
  border: none; font-size: 1.5rem; cursor: pointer; box-shadow: var(--shadow-lg);
  transition: all var(--transition-speed) ease; z-index: 999;
  display: flex; align-items: center; justify-content: center;
}
.fab:hover { transform: scale(1.1); }

/*--------------------------------------------------------------
12. Dark Theme Support for New Elements
--------------------------------------------------------------*/
body.dark-theme .share-modal-content {
  background: var(--bg-card);
  color: var(--text-dark);
}

body.dark-theme .share-url input {
  background: var(--bg-light);
  color: var(--text-dark);
  border-color: var(--border-color);
}

body.dark-theme .share-close:hover {
  background: var(--bg-light);
}

/*--------------------------------------------------------------
13. Responsive Design
--------------------------------------------------------------*/
@media (max-width: 768px) {
  .container { padding: 0 1rem; }
  .hero { padding-top: 100px; padding-bottom: 120px; }
  main.dashboard { margin-top: -80px; }
  .quick-actions { flex-direction: column; align-items: stretch; }
  .time-selector, .export-actions { justify-content: center; }
  
  .mobile-menu-toggle { display: block; }
  .nav-links {
    position: fixed; top: 70px; right: 0; bottom: 0; width: min(85vw, 400px);
    background-color: var(--bg-card); flex-direction: column; padding: 2rem; align-items: flex-start;
    gap: 1.5rem; transform: translateX(100%); transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: -5px 0 15px rgba(0,0,0,0.1);
  }
  .nav-links.is-open { transform: translateX(0); }

  /* Share modal mobile optimization */
  .share-modal-content {
    margin: 1rem;
    padding: 1.5rem;
  }

  .share-social {
    grid-template-columns: 1fr;
  }

  .hero-attribution {
    flex-direction: column;
    gap: 0.5rem;
  }

  .attribution-link {
    padding: 0.75rem 1.5rem;
  }

  /* Navigation buttons mobile spacing */
  .navbar > div {
    gap: 0.5rem !important;
  }

  .theme-toggle, .share-btn, .github-btn {
    width: 36px;
    height: 36px;
    font-size: 1rem;
  }
}