/**
 * Main Application Styles
 * Base styling for layout, typography, and components
 * Complements auth-styles.css for authentication UI
 */

/* ============================================================================
   GLOBAL RESET & BASE STYLES
   ============================================================================ */

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 1rem;
    line-height: 1.6;
    color: #333;
    background-color: #f5f7fa;
}

/* ============================================================================
   HEADER & NAVIGATION
   ============================================================================ */

header {
    background: white;
    border-bottom: 1px solid #e0e0e0;
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.header-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: #007bff;
    text-decoration: none;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.nav-buttons {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.nav-button {
    padding: 0.5rem 1rem;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 0.95rem;
    color: #007bff;
    transition: color 0.2s;
}

.nav-button:hover {
    color: #0056b3;
}

/* ============================================================================
   USER DROPDOWN
   ============================================================================ */

.user-menu {
    position: relative;
}

.user-button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border: 1px solid #ddd;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.user-button:hover {
    background: #f5f7fa;
    border-color: #007bff;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #007bff;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    min-width: 200px;
    display: none;
    z-index: 1000;
}

.dropdown-menu.show {
    display: block;
    animation: slideDown 0.2s ease;
}

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

.dropdown-menu a,
.dropdown-menu button {
    display: block;
    width: 100%;
    padding: 0.75rem 1.5rem;
    border: none;
    background: none;
    text-align: left;
    cursor: pointer;
    color: #333;
    transition: background 0.2s;
    font-size: 0.95rem;
    border-bottom: 1px solid #f0f0f0;
}

.dropdown-menu a:last-child,
.dropdown-menu button:last-child {
    border-bottom: none;
}

.dropdown-menu a:hover,
.dropdown-menu button:hover {
    background: #f5f7fa;
}

.dropdown-menu a.danger:hover,
.dropdown-menu button.danger:hover {
    background: #fee;
    color: #d32f2f;
}

/* ============================================================================
   MAIN CONTENT LAYOUT
   ============================================================================ */

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

.main-content {
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: 2rem;
}

/* ============================================================================
   SIDEBAR & FILTERS
   ============================================================================ */

.sidebar {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    height: fit-content;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.filter-section {
    margin-bottom: 2rem;
}

.filter-section:last-child {
    margin-bottom: 0;
}

.filter-title {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 0.75rem;
    color: #333;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.filter-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    color: #555;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.filter-group label:hover {
    color: #007bff;
}

.filter-group input[type="checkbox"],
.filter-group input[type="radio"] {
    cursor: pointer;
}

.filter-select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
    background: white;
}

.filter-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

.btn-filter {
    padding: 0.5rem 1rem;
    border: 1px solid #ddd;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.btn-filter:hover {
    border-color: #007bff;
    color: #007bff;
}

.btn-filter.clear {
    background: #f5f7fa;
}

/* ============================================================================
   MAIN CONTENT AREA
   ============================================================================ */

.content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* ============================================================================
   SEARCH BAR
   ============================================================================ */

.search-bar {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.search-input-wrapper {
    position: relative;
}

.search-input {
    width: 100%;
    padding: 0.75rem 2.5rem 0.75rem 1rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    transition: all 0.2s;
}

.search-input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.search-icon {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
    pointer-events: none;
}

/* ============================================================================
   DOCUMENTS LIST & CARDS
   ============================================================================ */

.results-header {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.results-count {
    color: #666;
    font-size: 0.95rem;
}

.results-actions {
    display: flex;
    gap: 1rem;
}

.btn-export {
    padding: 0.5rem 1rem;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.btn-export:hover {
    border-color: #007bff;
    color: #007bff;
}

.documents-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.5rem;
}

.documents-empty {
    grid-column: 1 / -1;
    padding: 3rem 2rem;
    text-align: center;
    color: #999;
}

.documents-empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.documents-empty-text {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.documents-empty-hint {
    font-size: 0.9rem;
    color: #bbb;
}

.document-card {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: all 0.2s;
    cursor: pointer;
    border: 1px solid transparent;
}

.document-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-color: #007bff;
    transform: translateY(-2px);
}

.document-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.document-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #007bff;
    margin: 0;
    flex: 1;
    word-break: break-word;
}

.document-card:hover .document-title {
    text-decoration: underline;
}

.document-status {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-left: 0.5rem;
}

.document-status.current {
    background: #d4edda;
    color: #155724;
}

.document-status.superseded {
    background: #e2e3e5;
    color: #383d41;
}

.document-status.pending {
    background: #fff3cd;
    color: #856404;
}

.document-status.repealed {
    background: #f8d7da;
    color: #721c24;
}

.document-meta {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
    font-size: 0.85rem;
}

.document-meta-item {
    display: flex;
    flex-direction: column;
}

.document-meta-label {
    color: #999;
    font-size: 0.75rem;
    text-transform: uppercase;
    margin-bottom: 0.25rem;
}

.document-meta-value {
    color: #333;
    font-weight: 500;
}

.document-citation {
    background: #f5f7fa;
    padding: 0.75rem;
    border-left: 3px solid #007bff;
    margin: 1rem 0;
    font-size: 0.85rem;
    font-family: 'Courier New', monospace;
    border-radius: 2px;
}

.document-preview {
    font-size: 0.9rem;
    color: #666;
    line-height: 1.5;
    margin: 1rem 0;
    padding: 0.75rem;
    background: #f9f9f9;
    border-radius: 4px;
    max-height: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.document-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.btn-card {
    flex: 1;
    padding: 0.5rem 1rem;
    border: 1px solid #ddd;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.btn-card:hover {
    border-color: #007bff;
    color: #007bff;
}

.btn-card.primary {
    background: #007bff;
    color: white;
    border-color: #007bff;
}

.btn-card.primary:hover {
    background: #0056b3;
    border-color: #0056b3;
}

/* ============================================================================
   MODALS & DIALOGS
   ============================================================================ */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 8px;
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    animation: modalSlide 0.3s ease;
}

@keyframes modalSlide {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

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

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #999;
    transition: color 0.2s;
}

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

.modal-body {
    margin-bottom: 1.5rem;
}

.modal-footer {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

.btn-modal {
    padding: 0.75rem 1.5rem;
    border: 1px solid #ddd;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.95rem;
    transition: all 0.2s;
}

.btn-modal:hover {
    border-color: #007bff;
    color: #007bff;
}

.btn-modal.primary {
    background: #007bff;
    color: white;
    border-color: #007bff;
}

.btn-modal.primary:hover {
    background: #0056b3;
}

/* ============================================================================
   PAGINATION
   ============================================================================ */

.pagination {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin-top: 2rem;
}

.pagination button {
    padding: 0.5rem 0.75rem;
    border: 1px solid #ddd;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.pagination button:hover {
    border-color: #007bff;
    color: #007bff;
}

.pagination button.active {
    background: #007bff;
    color: white;
    border-color: #007bff;
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================================================
   LANDING PAGE / HERO
   ============================================================================ */

.hero {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    color: white;
    padding: 4rem 2rem;
    text-align: center;
}

.hero-content {
    max-width: 800px;
    margin: 0 auto;
}

.hero h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    font-weight: 700;
}

.hero p {
    font-size: 1.1rem;
    margin-bottom: 2rem;
    opacity: 0.95;
}

.hero-form {
    background: white;
    border-radius: 8px;
    padding: 2rem;
    max-width: 500px;
    margin: 0 auto;
    color: #333;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.hero-form h2 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: #333;
}

/* ============================================================================
   LOADING STATES
   ============================================================================ */

.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* ============================================================================
   RESPONSIVE DESIGN
   ============================================================================ */

@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }

    .sidebar {
        display: none;
    }

    .container {
        padding: 1.5rem;
    }

    .documents-container {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    }
}

@media (max-width: 768px) {
    .header-container {
        padding: 0 1rem;
        flex-wrap: wrap;
    }

    .nav-right {
        gap: 1rem;
    }

    .documents-container {
        grid-template-columns: 1fr;
    }

    .document-meta {
        grid-template-columns: 1fr;
    }

    .hero h1 {
        font-size: 1.8rem;
    }

    .hero-form {
        padding: 1.5rem;
    }

    .search-bar {
        padding: 1rem;
    }

    .results-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
}

@media (max-width: 480px) {
    .header-container {
        padding: 0 1rem;
    }

    .logo {
        font-size: 1.2rem;
    }

    .nav-right {
        gap: 0.75rem;
    }

    .container {
        padding: 1rem;
    }

    .hero {
        padding: 2rem 1rem;
    }

    .hero h1 {
        font-size: 1.5rem;
    }

    .hero p {
        font-size: 1rem;
    }

    .modal-content {
        width: 95%;
        padding: 1.5rem;
    }

    .document-card {
        padding: 1rem;
    }

    .document-title {
        font-size: 1rem;
    }

    .search-input {
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

/* ============================================================================
   DARK MODE SUPPORT
   ============================================================================ */

@media (prefers-color-scheme: dark) {
    body {
        background-color: #1a1a1a;
        color: #e0e0e0;
    }

    header {
        background: #2d2d2d;
        border-bottom-color: #444;
    }

    .sidebar,
    .search-bar,
    .results-header,
    .document-card,
    .modal-content {
        background: #2d2d2d;
        color: #e0e0e0;
    }

    .document-card {
        border-color: #444;
    }

    .document-card:hover {
        border-color: #007bff;
    }

    .document-title {
        color: #4fa3ff;
    }

    .document-citation {
        background: #3d3d3d;
        color: #e0e0e0;
        border-left-color: #007bff;
    }

    .document-preview {
        background: #3d3d3d;
        color: #b0b0b0;
    }

    .search-input,
    .filter-select {
        background: #3d3d3d;
        color: #e0e0e0;
        border-color: #444;
    }

    .search-input:focus {
        border-color: #4fa3ff;
    }

    .btn-card,
    .btn-filter,
    .btn-export,
    .btn-modal {
        background: #3d3d3d;
        color: #e0e0e0;
        border-color: #444;
    }

    .btn-card:hover,
    .btn-filter:hover,
    .btn-export:hover,
    .btn-modal:hover {
        border-color: #007bff;
        color: #4fa3ff;
    }

    .dropdown-menu {
        background: #2d2d2d;
        border-color: #444;
    }

    .dropdown-menu a,
    .dropdown-menu button {
        color: #e0e0e0;
        border-bottom-color: #444;
    }

    .dropdown-menu a:hover,
    .dropdown-menu button:hover {
        background: #3d3d3d;
    }

    .user-button {
        background: #3d3d3d;
        color: #e0e0e0;
        border-color: #444;
    }

    .filter-group label {
        color: #b0b0b0;
    }

    .results-count {
        color: #b0b0b0;
    }

    .documents-empty {
        color: #666;
    }

    .documents-empty-hint {
        color: #555;
    }
}

/* ============================================================================
   ACCESSIBILITY
   ============================================================================ */

@media (prefers-reduced-motion: reduce) {
    .document-card,
    .dropdown-menu,
    .modal-content,
    button,
    a {
        animation: none !important;
        transition: none !important;
    }
}

/* Focus visible for keyboard navigation */
button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* ============================================================================
   PRINT STYLES
   ============================================================================ */

@media print {
    header,
    .sidebar,
    .search-bar,
    .results-header,
    .pagination,
    .document-actions {
        display: none;
    }

    .document-card {
        box-shadow: none;
        border: 1px solid #ddd;
        page-break-inside: avoid;
    }

    .container {
        max-width: 100%;
        padding: 0;
    }
}
