/* Main Styles for Govset Application */

:root {
    --header-height: 80px; /* Centralized header height for consistent calculations */
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: white;
    color: #333;
    overflow-x: hidden;
}

/* Header */
.header {
    background: #000;
    color: white;
    padding: 1rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    height: var(--header-height); /* Use CSS custom property for consistent height */
    display: flex;
    align-items: center;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.header h1 {
    font-family: 'Instrument Serif', serif;
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
}

.logo-link {
    color: white;
    text-decoration: none;
}

.logo-link:hover {
    color: white;
}

.header-nav {
    display: flex;
    gap: 2rem;
}

.nav-link {
    color: white;
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    transition: opacity 0.2s;
}

.nav-link:hover {
    opacity: 0.8;
}

/* Main Layout */
.main-layout {
    display: flex;
    min-height: calc(100vh - var(--header-height));
}

/* Sidebar */
.sidebar {
    width: 25%;
    min-width: 300px; /* Minimum width to prevent content from being too cramped */
    max-width: 400px; /* Maximum width to prevent taking too much space */
    background: #fafafa;
    border-right: 1px solid #e0e0e0;
    position: sticky;
    top: var(--header-height); /* Stick below the header */
    height: calc(100vh - var(--header-height)); /* Full viewport height minus header height */
    overflow-y: auto;
    overflow-x: hidden; /* Prevent horizontal scrolling */
    padding: 1.5rem;
    box-sizing: border-box; /* Include padding in width calculation */
}

.search-container {
    margin-bottom: 2rem;
}

.search-input {
    width: 100%;
    padding: 1rem;
    border: 2px solid #e0e0e0;
    font-size: 1rem;
    transition: border-color 0.2s;
    box-sizing: border-box; /* Include padding and border in width calculation */
    min-width: 0; /* Allow input to shrink below its content size */
}

.search-input:focus {
    outline: none;
    border-color: #1e40af;
}

.search-input.enabled {
    opacity: 1 !important;
    cursor: text !important;
    pointer-events: auto !important;
    background-color: white !important;
    color: #333 !important;
}

.search-input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background-color: #f5f5f5;
}

.search-results {
    margin-top: 1.5rem;
}

.search-result-item {
    background: white;
    border: 1px solid #e0e0e0;
    padding: 1rem;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
    box-sizing: border-box; /* Include padding and border in width calculation */
    overflow-wrap: break-word; /* Break long words to prevent horizontal overflow */
    word-wrap: break-word; /* Legacy support for word breaking */
}

.search-result-item:hover {
    box-shadow: 0 2px 8px rgba(30, 64, 175, 0.1);
    border-color: #1e40af;
}

.search-result-item.active {
    border-color: #1e40af;
    background: #f0f4ff;
}

.result-title {
    font-weight: 600;
    color: #1e40af;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.result-meta {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 0.3rem;
}

.result-date {
    font-size: 0.8rem;
    color: #888;
}

/* Main Content */
.main-content {
    flex: 1; /* Take remaining space after sidebar */
    background: white;
    padding: 2rem;
    overflow-y: auto;
    overflow-x: hidden; /* Prevent horizontal scrolling */
    box-sizing: border-box; /* Include padding in width calculation */
}

/* Breadcrumbs */
.breadcrumbs {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e0e0e0;
}

.breadcrumbs a {
    color: #1e40af;
    text-decoration: none;
    font-size: 0.9rem;
}

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

.breadcrumbs span {
    color: #666;
    margin: 0 0.5rem;
}

/* Record Header */
.record-header {
    margin-bottom: 2rem;
}

.record-title {
    font-size: 1.8rem;
    font-weight: 700;
    color: #1e40af;
    margin-bottom: 1rem;
}

.record-description {
    font-size: 1.1rem;
    line-height: 1.6;
    color: #555;
    margin-bottom: 1.5rem;
}

/* Record Details Section */
.record-details {
    margin-bottom: 2rem;
    border: 1px solid #e0e0e0;
    background: white;
}

.details-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
}

.hide-details-btn {
    background: #1e40af;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: background 0.2s;
}

.hide-details-btn:hover {
    background: #1e3a8a;
}

.details-content {
    transition: all 0.3s ease;
    overflow: hidden;
}

.details-content.collapsed {
    max-height: 0;
    padding: 0;
}

/* Metadata Navigation */
.metadata-nav {
    display: flex;
    border-bottom: 1px solid #e0e0e0;
    background: #fafafa;
}

.metadata-nav-btn {
    background: none;
    border: none;
    padding: 1rem 1.5rem;
    cursor: pointer;
    font-weight: 500;
    color: #666;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.metadata-nav-btn:hover {
    background: #f0f0f0;
    color: #333;
}

.metadata-nav-btn.active {
    color: #1e40af;
    border-bottom-color: #1e40af;
    background: white;
}

/* Metadata Content */
.metadata-content-container {
    position: relative;
    min-height: 200px;
}

.metadata-panel {
    display: none;
    padding: 2rem;
    animation: fadeIn 0.3s ease;
}

.metadata-panel.active {
    display: block;
}

.metadata-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.metadata-row:last-child {
    margin-bottom: 0;
}

.metadata-field {
    flex: 1;
    min-width: 200px;
}

.metadata-label {
    font-weight: 600;
    color: #333;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.metadata-value {
    color: #666;
    font-size: 0.9rem;
    line-height: 1.5;
}

.tag {
    display: inline-block;
    background: #1e40af;
    color: white;
    padding: 0.3rem 0.6rem;
    margin: 0.2rem;
    font-size: 0.8rem;
    font-weight: 500;
}

/* Entity and Address Lists */
.entity-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.entity-item {
    background: #f0f4ff;
    color: #1e40af;
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    font-weight: 500;
    border: 1px solid #e0e8ff;
}

.address-list, .plat-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.address-list li, .plat-list li {
    padding: 0.5rem 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.9rem;
}

.address-list li:last-child, .plat-list li:last-child {
    border-bottom: none;
}

.plat-id {
    background: #1e40af;
    color: white;
    padding: 0.2rem 0.5rem;
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    font-weight: 600;
    margin-right: 0.5rem;
}

/* PDF Reader Placeholder */
.pdf-reader-container {
    border: 2px solid #e0e0e0;
    min-height: 600px;
    background: #f9f9f9;
    margin-top: 1.5rem;
}

.placeholder-content {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 600px;
    color: #666;
    font-size: 1.1rem;
}

/* Agencies Page Styles */
.agencies-header {
    margin-bottom: 2rem;
}

.agencies-title {
    font-size: 1.8rem;
    font-weight: 700;
    color: #1e40af;
    margin-bottom: 1rem;
}

.agencies-description {
    font-size: 1.1rem;
    line-height: 1.6;
    color: #555;
    margin-bottom: 1.5rem;
}

.agencies-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}

.agency-card {
    border: 1px solid #e0e0e0;
    background: white;
    cursor: pointer;
    transition: all 0.2s;
    overflow: hidden;
    display: flex;
    align-items: center;
    padding: 1.5rem;
}

.agency-card:hover {
    box-shadow: 0 4px 12px rgba(30, 64, 175, 0.1);
    border-color: #1e40af;
    transform: translateY(-1px);
}

.agency-card-content {
    flex: 1;
}

.agency-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.8rem;
}

.agency-card-name {
    font-size: 1.2rem;
    font-weight: 600;
    color: #1e40af;
}

.agency-card-type {
    background: #f0f4ff;
    color: #1e40af;
    padding: 0.3rem 0.8rem;
    font-size: 0.85rem;
    font-weight: 500;
}

.agency-card-meta {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    font-size: 0.9rem;
    color: #666;
}

.agency-card-state {
    color: #888;
}

.search-filter-bar {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
}

.search-filter-container {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.search-filter-container input,
.search-filter-container select {
    padding: 0.8rem;
    border: 2px solid #e0e0e0;
    font-size: 0.9rem;
    transition: border-color 0.2s;
    border-radius: 0;
}

.search-filter-container input:focus,
.search-filter-container select:focus {
    outline: none;
    border-color: #1e40af;
}

#agencySearch {
    flex: 1;
    min-width: 300px;
}

.filter-group {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.filter-label {
    font-size: 0.9rem;
    font-weight: 500;
    color: #333;
}

.agency-card-links {
    display: flex;
    gap: 0.5rem;
    margin-left: auto;
}

.agency-link {
    padding: 0.3rem 0.6rem;
    background: #f8f9fa;
    color: #666;
    text-decoration: none;
    font-size: 0.8rem;
    border: 1px solid #e0e0e0;
    transition: all 0.2s;
}

.agency-link:hover {
    background: #1e40af;
    color: white;
    border-color: #1e40af;
}

.loading-spinner {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    color: #666;
}

.spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #1e40af;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.end-message {
    text-align: center;
    padding: 2rem;
    color: #666;
    font-style: italic;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #1e40af;
}

::-webkit-scrollbar-thumb:hover {
    background: #1e3a8a;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.visible {
    display: block !important;
}

/* Loading Animation Styles */
.search-loading-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem 0;
}

.search-loading-text {
    color: #666;
    font-size: 1.1rem;
    font-weight: 500;
}

.search-loading-dots {
    display: flex;
    gap: 3px;
}

.search-dot {
    width: 5px;
    height: 5px;
    background-color: #1e40af;
    border-radius: 50%;
    animation: search-bounce 1.4s ease-in-out infinite both;
}

.search-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.search-dot:nth-child(2) {
    animation-delay: -0.16s;
}

.search-dot:nth-child(3) {
    animation-delay: 0s;
}

@keyframes search-bounce {
    0%, 80%, 100% {
        transform: scale(0);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

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

/* Responsive Design */
@media (max-width: 1024px) {
    .sidebar {
        width: 30%;
        min-width: 280px;
    }
    
    .main-content {
        padding: 1.5rem;
    }
}

@media (max-width: 768px) {
    .main-layout {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        max-height: 40vh;
        position: relative;
        top: 0;
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
    }
    
    .main-content {
        width: 100%;
        padding: 1rem;
    }
}
