/* Modern Enhancements for Atabak's Blog - Bootstrap 2 Compatible */

/* Root Variables for Consistent Theming */
:root {
  --primary-color: #2c3e50;
  --secondary-color: #3498db;
  --accent-color: #e74c3c;
  --text-color: #2c3e50;
  --text-light: #7f8c8d;
  --background-color: #ffffff;
  --border-color: #ecf0f1;
  --shadow: 0 2px 4px rgba(0,0,0,0.1);
  --border-radius: 8px;
  --transition: all 0.3s ease;
  --table-header-bg: #2c3e50;
  --table-header-color: #ffffff;
  --table-hover-bg: #f8f9fa;
  --code-bg: #f8f9fa;
  --inline-code-bg: #f1f3f4;
  --blockquote-bg: #f8f9fa;
  --surface-muted: #f8f9fa;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  :root {
    --primary-color: #ecf0f1;
    --secondary-color: #3498db;
    --text-color: #ecf0f1;
    --text-light: #bdc3c7;
    --background-color: #2c3e50;
    --border-color: #34495e;
    --table-header-bg: #1a252f;
    --table-header-color: #ffffff;
    --table-hover-bg: #34495e;
    --code-bg: #1a252f;
    --inline-code-bg: #1a252f;
    --blockquote-bg: #34495e;
    --surface-muted: #34495e;
  }
}

/* Enhanced Typography */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  line-height: 1.6;
  color: var(--text-color);
  background-color: var(--background-color);
  transition: var(--transition);
}

/* Improved Post Styling - Bootstrap 2 Compatible */
.ghpb-post {
  background: var(--background-color);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  padding: 2rem;
  margin-bottom: 2rem;
  border: 1px solid var(--border-color);
  transition: var(--transition);
}

.ghpb-post:hover {
  box-shadow: 0 4px 8px rgba(0,0,0,0.15);
  transform: translateY(-2px);
}

.ghpb-post h1, .ghpb-post h2, .ghpb-post h3 {
  color: var(--primary-color);
  margin-top: 1.5rem;
  margin-bottom: 1rem;
}

.ghpb-post h1 {
  font-size: 2.5rem;
  font-weight: 700;
  line-height: 1.2;
}

.ghpb-post h2 {
  font-size: 2rem;
  font-weight: 600;
}

.ghpb-post h3 {
  font-size: 1.5rem;
  font-weight: 500;
}

/* Enhanced Code Blocks */
.ghpb-post pre {
  background: var(--code-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 1rem;
  overflow-x: auto;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 0.9rem;
  line-height: 1.4;
  color: var(--text-color);
}

.ghpb-post code {
  background: var(--inline-code-bg);
  color: var(--text-color);
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 0.9em;
}

.ghpb-post pre code {
  background: transparent;
  padding: 0;
}

/* Improved Navigation - Bootstrap 2 Compatible */
.navbar {
  background: var(--primary-color) !important;
  box-shadow: var(--shadow);
  border: none;
}

/* Desktop navbar must stay expanded; mobile uses Bootstrap collapse. */
@media (min-width: 980px) {
  .navbar .nav-collapse,
  .navbar .nav-collapse.collapse {
    display: block !important;
    height: auto !important;
    overflow: visible !important;
  }

  .navbar .nav-collapse::after {
    content: "";
    display: table;
    clear: both;
  }
}

/* Fix dropdown positioning - only open the direct child menu */
.navbar .dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 1000;
  display: none;
  float: left;
  min-width: 160px;
  padding: 5px 0;
  margin: 2px 0 0;
  list-style: none;
  background-color: #ffffff;
  border: 1px solid #ccc;
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 4px;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);
}

.navbar .dropdown.open > .dropdown-menu {
  display: block;
}

/* Fix submenu positioning */
.navbar .dropdown-submenu {
  position: relative;
}

.navbar .dropdown-submenu > .dropdown-menu {
  top: 0;
  left: 100%;
  margin-top: -6px;
  margin-left: -1px;
  display: none;
}

.navbar .dropdown-submenu.open > .dropdown-menu {
  display: block;
}

/* Dark bio card uses the same color as body text; force readable contrast */
.span4 > .well {
  color: #ecf0f1;
}

.span4 > .well a {
  color: #5dade2;
}

.span4 > .well a:hover {
  color: #85c1e9;
}

.navbar .brand {
  font-weight: 700;
  font-size: 1.5rem;
  color: white !important;
}

.navbar .nav > li > a {
  color: rgba(255,255,255,0.9) !important;
  transition: var(--transition);
}

.navbar .nav > li > a:hover {
  color: white !important;
  background: rgba(255,255,255,0.1);
}

/* Enhanced Buttons - Bootstrap 2 Compatible */
.btn {
  border-radius: var(--border-radius);
  transition: var(--transition);
  font-weight: 500;
}

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

/* Improved Images */
.ghpb-post img {
  max-width: 100%;
  height: auto;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  margin: 1rem 0;
  transition: var(--transition);
}

.ghpb-post img:hover {
  transform: scale(1.02);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

/* Enhanced Lists */
.ghpb-post ul, .ghpb-post ol {
  padding-left: 1.5rem;
}

.ghpb-post li {
  margin-bottom: 0.5rem;
  line-height: 1.6;
}

/* Improved Blockquotes */
.ghpb-post blockquote {
  border-left: 4px solid var(--secondary-color);
  background: var(--blockquote-bg);
  padding: 1rem 1.5rem;
  margin: 1.5rem 0;
  border-radius: 0 var(--border-radius) var(--border-radius) 0;
  font-style: italic;
  color: var(--text-light);
}

.personal-disclaimer {
  background: var(--surface-muted);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-color);
  font-size: 0.95em;
  line-height: 1.5;
  margin: 1.5rem 0;
  padding: 1rem 1.25rem;
}

/* Enhanced Tables */
.ghpb-post table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  background: var(--background-color);
  border-radius: var(--border-radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  color: var(--text-color);
}

.ghpb-post th, .ghpb-post td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.ghpb-post thead th,
.ghpb-post th {
  background: var(--table-header-bg);
  color: var(--table-header-color);
  font-weight: 600;
}

.ghpb-post tbody tr:hover {
  background: var(--table-hover-bg);
}

/* Reading Progress Bar */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 0%;
  height: 3px;
  background: var(--secondary-color);
  z-index: 1000;
  transition: width 0.3s ease;
}

/* Social Sharing Buttons */
.social-share {
  margin: 2rem 0;
  padding: 1rem;
  background: var(--surface-muted);
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
}

.social-share h4 {
  margin-bottom: 1rem;
  color: var(--primary-color);
}

.share-buttons {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.share-btn {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 1rem;
  background: var(--secondary-color);
  color: white;
  text-decoration: none;
  border-radius: var(--border-radius);
  transition: var(--transition);
  font-size: 0.9rem;
}

.share-btn:hover {
  background: var(--primary-color);
  color: white;
  text-decoration: none;
  transform: translateY(-1px);
}

/* Reading Time */
.reading-time {
  margin: 1rem 0;
  padding: 0.5rem;
  background: var(--surface-muted);
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
  text-align: center;
}

/* Custom Layout System - Override Bootstrap 2 completely */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 15px;
}

.container .row {
  display: flex;
  flex-wrap: wrap;
  margin: 0;
  padding: 0;
}

/* Sidebar - Left Column */
.container .span4 {
  flex: 0 0 33.333333%;
  max-width: 33.333333%;
  padding: 0 15px;
  box-sizing: border-box;
  float: none !important;
  width: auto !important;
  margin: 0 !important;
}

/* Main Content - Right Column */
.container .span8 {
  flex: 0 0 66.666667%;
  max-width: 66.666667%;
  padding: 0 15px;
  box-sizing: border-box;
  float: none !important;
  width: auto !important;
  margin: 0 !important;
}

/* Responsive Design Improvements - Bootstrap 2 Compatible */
@media (max-width: 768px) {
  .ghpb-post {
    padding: 1rem;
    margin-bottom: 1rem;
  }
  
  .ghpb-post h1 {
    font-size: 2rem;
  }
  
  .ghpb-post h2 {
    font-size: 1.5rem;
  }
  
  .share-buttons {
    flex-direction: column;
  }
  
  .share-btn {
    justify-content: center;
  }
  
  /* Bootstrap 2 responsive adjustments */
  .container {
    padding-left: 10px;
    padding-right: 10px;
  }
  
  .container .row {
    flex-direction: column;
  }

  body > .container > .row:first-child > .span8 {
    order: 1;
  }

  body > .container > .row:first-child > .span4 {
    order: 2;
  }
  
  .container .span4, .container .span8 {
    flex: 0 0 100%;
    max-width: 100%;
    padding: 0 10px;
  }
}

/* Print Styles */
@media print {
  .navbar, .social-share, .reading-progress {
    display: none;
  }
  
  .ghpb-post {
    box-shadow: none;
    border: 1px solid #ccc;
  }
}

/* Accessibility Improvements */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Focus styles for keyboard navigation */
a:focus, button:focus, input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--secondary-color);
  outline-offset: 2px;
}

/* Skip to content link */
.skip-link {
  position: absolute;
  top: -40px;
  left: 6px;
  background: var(--primary-color);
  color: white;
  padding: 8px;
  text-decoration: none;
  z-index: 1000;
}

.skip-link:focus {
  top: 6px;
}

/* Bootstrap 2 specific fixes */
.well {
  background-color: var(--background-color);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
}

.ghpb-well-outline {
  background-color: transparent;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
}

/* Force override all Bootstrap 2 grid system */
* {
  box-sizing: border-box;
}

.container .row {
  display: flex !important;
  flex-wrap: wrap !important;
  margin: 0 !important;
  padding: 0 !important;
}

.container .span4,
.container .span8 {
  position: relative !important;
  min-height: 1px !important;
  float: none !important;
  display: block !important;
}

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