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

body {
    font-family: 'Arial', sans-serif;
    background-color: #f9f9f9;
    padding-top: 90px; /* Increased for better clearance */
}

/* Navbar - Funlearn style for consti-learn */
:root {
  --primary: #ff6700;
  --orange: #ffb38a;
  --bg: #f8f9fa;
  --white: #fff;
  --shadow: 0 6px 38px 0 rgba(255,103,0,0.06);
  --radius: 18px;
}

.funlearn-navbar {
  display: flex;
  flex-direction: row; /* Changed to row for desktop */
  justify-content: space-between; /* Space between logo and links */
  align-items: center;
  background: #fff;
  border-bottom: 2.5px solid #ffe8d8;
  padding: 0 2vw;
  height: 64px;
  box-shadow: 0 2px 12px #ff670003;
  z-index: 100;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
}

.nav-top-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0;
}

.funlearn-logo-link {
  display: flex;
  align-items: center;
  text-decoration: none;
  z-index: 10;
}

.funlearn-logo {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  margin-right: 7px;
  box-shadow: 0 2px 12px #ffd7b545;
}

.funlearn-navbar-title {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -1px;
  user-select: none;
}

/* Mobile menu toggle button */
.mobile-menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 10px;
  z-index: 10;
}

.hamburger-icon {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 27px;
  height: 20px;
}

.hamburger-icon span {
  display: block;
  height: 3px;
  width: 100%;
  background-color: var(--primary);
  border-radius: 3px;
  transition: all 0.2s ease-in-out;
}

.hamburger-icon.active span:nth-child(1) {
  transform: translateY(8.5px) rotate(45deg);
}

.hamburger-icon.active span:nth-child(2) {
  opacity: 0;
}

.hamburger-icon.active span:nth-child(3) {
  transform: translateY(-8.5px) rotate(-45deg);
}

.funlearn-navbar-links {
  display: flex;
  gap: 36px;
  list-style: none;
  margin: 0;
  padding: 0;
  align-items: center;
}

.funlearn-navbar-links li a {
  font-size: 1.09rem;
  color: #444;
  font-weight: 500;
  text-decoration: none;
  opacity: 0.87;
  transition: color 0.17s;
  position: relative;
  padding: 4px 0;
}

.funlearn-navbar-links li a.active,
.funlearn-navbar-links li a:hover {
  color: var(--primary);
  opacity: 1;
}

.nav-link.active {
  color: var(--primary) !important;
  font-weight: 600;
}

/* Underline animation for nav links */
.underline-anim {
  display: inline-block;
  position: relative;
}

.underline-anim::after {
  content: '';
  display: block;
  position: absolute;
  left: 0;
  bottom: -2px;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, var(--orange), var(--primary) 70%);
  border-radius: 2px;
  transform: scaleX(0);
  transition: transform 0.25s cubic-bezier(.77,0,.18,1);
  transform-origin: left;
}

.underline-anim:hover::after, 
.underline-anim:focus::after, 
.underline-anim.active::after {
  transform: scaleX(1);
}

/* CONSTITUTION PAGE STYLES */
.main-content {
    margin-top: 30px; /* Increased from 20px to 30px */
}

/* Adjust card positioning */
.card.mt-4 {
    margin-top: 1.8rem !important; /* Slightly more margin for first card */
}

/* Table and pagination container styles */
.table-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.table-scroll-area {
    max-height: 60vh;
    overflow-y: auto;
    margin-bottom: 10px;
    border: 1px solid rgba(0,0,0,.125);
    border-radius: 0.25rem;
}

.table {
    margin-bottom: 0;
    box-shadow: none;
}

.pagination-container {
    padding-top: 15px;
    border-top: 1px solid #eee;
}

.highlight {
    background-color: yellow;
}

td {
    font-family: 'Arial', sans-serif;
}

.article-link {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

.article-link:hover {
    color: #0d6efd;
}

/* Search related styles */
#clearSearchBtn {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

#searchBtn {
    border-radius: 0;
}

#searchStatusContainer {
    background-color: #f8f9fa;
    padding: 8px 12px;
    border-radius: 5px;
    margin-top: 5px;
}

#backToAllBtn {
    white-space: nowrap;
    padding: 4px 10px;
    font-size: 0.9rem;
}

/* Modal styling */
.article-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(3px);
    overflow: hidden; /* Prevent outer scroll */
}

.modal-content {
    background-color: #fff;
    margin: 5% auto;
    padding: 20px;
    width: 80%;
    max-width: 800px;
    max-height: 90vh; /* Limit height to 90% of viewport */
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    animation: fadeIn 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Hide overflow on container */
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #dee2e6;
    padding-bottom: 15px;
    margin-bottom: 20px;
    flex-shrink: 0; /* Prevent header from shrinking */
}

.modal-title {
    font-weight: 600;
    margin: 0;
}

.close-modal {
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    border: none;
    background: none;
}

.close-modal:hover {
    color: #dc3545;
}

.modal-body {
    flex-grow: 1; /* Allow body to take available space */
    overflow-y: auto; /* Enable vertical scrolling */
    padding: 10px 0;
    margin-bottom: 15px;
    max-height: calc(90vh - 150px); /* Adjusted to account for header/footer */
}

.modal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid #dee2e6;
    padding-top: 15px;
    flex-shrink: 0; /* Prevent footer from shrinking */
}

.synopsis-section {
    background-color: #f8f9fa;
    padding: 15px;
    border-radius: 5px;
    margin-top: 20px;
}

.tab-content {
    padding: 15px 0;
}

.language-switch {
    display: flex;
    gap: 10px;
    margin: 0;
    flex-wrap: wrap;
}


.loading-spinner {
    display: flex;
    justify-content: center;
    padding: 30px;
}

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

/* Language switcher */
.language-btn, .language-selector {
    border: 2px solid #0d6efd;
    background-color: transparent;
    color: #0d6efd;
    border-radius: 20px;
    padding: 5px 15px;
    transition: all 0.3s;
    font-weight: 500;
}

.language-btn.active, .language-selector.active {
    background-color: #0d6efd;
    color: white;
}

.language-btn:hover:not(.active), .language-selector:hover:not(.active) {
    background-color: #e9ecef;
}

/* Table styling improvements */
.table {
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.table thead {
    background-color: #f8f9fa;
    position: sticky;
    top: 0;
    z-index: 10;
}

.table thead th {
    border-bottom-width: 2px;
}

.table-hover tbody tr:hover {
    background-color: #f1f8ff;
}

/* Pagination styling */
.pagination-container {
    margin-top: 15px;
    margin-bottom: 10px;
}

.pagination .page-link {
    color: #0d6efd;
    background-color: #fff;
    border-color: #dee2e6;
    padding: 0.5rem 0.75rem;
    font-size: 0.95rem;
    min-width: 38px;
    text-align: center;
}

.pagination .page-item.active .page-link {
    background-color: #0d6efd;
    border-color: #0d6efd;
    color: white;
    font-weight: 600;
}

.pagination .page-link:focus {
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

.pagination .page-link:hover {
    background-color: #e9ecef;
    border-color: #dee2e6;
    color: #0a58ca;
}

.pagination .page-item.disabled .page-link {
    color: #6c757d;
    pointer-events: none;
    background-color: #fff;
    border-color: #dee2e6;
}

html, body {
    margin: 0;
    padding: 0;
}

/* Responsive Navbar - Only apply these changes for mobile */
@media (max-width: 900px) {
  .funlearn-navbar {
    flex-direction: column;
    height: auto;
    padding: 0 15px;
  }
  
  .nav-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    width: 100%;
  }
  
  .mobile-menu-toggle {
    display: block;
  }
  
  .funlearn-navbar-links {
    flex-direction: column;
    gap: 15px;
    width: 100%;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-in-out;
    padding: 0;
    align-items: flex-start;
  }
  
  .funlearn-navbar-links.active {
    max-height: 500px;
    padding: 10px 0 20px 0;
  }
  
  .funlearn-navbar-links li {
    width: 100%;
  }
  
  .funlearn-navbar-links li a {
    display: block;
    padding: 8px 0;
  }
  
  body {
    padding-top: 56px;
  }
  
  /* Make table area smaller on mobile */
  .table-scroll-area {
    max-height: 50vh;
  }
}

/* Additional mobile responsive styles */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        margin: 5% auto;
        padding: 15px;
    }
    
    .modal-title {
        font-size: 18px;
    }
    
    .modal-body {
        max-height: 70vh;
    }
    
    .tab-content {
        padding: 10px 0;
    }
    
    .table th, .table td {
        padding: 8px;
        font-size: 14px;
    }
    
    .card-body {
        padding: 15px;
    }
    
    .input-group {
        width: 100%;
    }
    
    .language-switch {
        flex-wrap: wrap;
    }
    
    .language-btn {
        font-size: 14px;
        padding: 4px 12px;
    }
    
    /* Pagination mobile styling */
    .pagination .page-link {
        padding: 0.4rem 0.6rem;
        font-size: 0.9rem;
        min-width: 32px;
    }
    
    /* Search button text hiding on smaller screens */
    .btn-text {
        display: none;
    }
}

@media (max-width: 576px) {
    body {
        padding-top: 56px;
    }
    
    .main-content {
        margin-top: 10px;
        padding: 0 8px;
    }
    
    .modal-content {
        margin: 10% auto;
        padding: 12px;
    }
    
    .modal-header {
        padding-bottom: 10px;
        margin-bottom: 15px;
    }
    
    .table th, .table td {
        padding: 6px;
        font-size: 13px;
    }
    
    .card {
        margin-bottom: 12px;
    }
    
    /* Mobile pagination compact style */
    .pagination {
        flex-wrap: wrap;
        justify-content: center;
        gap: 5px;
    }
    
    .pagination .page-link {
        padding: 0.35rem 0.5rem;
        font-size: 0.85rem;
        min-width: 30px;
    }
    
    /* Hide some pagination items on very small screens */
    .pagination-compact .page-item.extra {
        display: none;
    }
    
    .input-group {
        flex-wrap: nowrap;
    }
    
    #searchBtn, #clearSearchBtn {
        padding-left: 10px;
        padding-right: 10px;
    }
}

/* Improved touch target sizes for mobile */
@media (max-width: 480px) {
    .btn {
        padding: 8px 16px;
    }
    
    .nav-tabs .nav-link {
        padding: 8px 10px;
        font-size: 14px;
    }
    
    .article-link {
        display: block;
        padding: 5px 0;
    }
    
    .modal-footer {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }
    
    .language-switch {
        justify-content: center;
    }
    
    /* Make pagination even more compact on tiny screens */
    .pagination .page-link {
        min-width: 28px;
        font-size: 0.8rem;
    }
    
    #backToAllBtn {
        padding: 3px 8px;
        font-size: 0.8rem;
    }
    
    #searchStatus {
        font-size: 0.85rem;
    }
    
    /* Table area even smaller on tiny screens */
    .table-scroll-area {
        max-height: 45vh;
    }
}