/* =============================================================================
   Bluebook Citation Generator - Styles
   Modern Academic Design
   ============================================================================= */

:root {
    --primary: #2d3748;
    --primary-light: #4a5568;
    --accent: #9b2c2c;
    --accent-light: #c53030;
    --bg: #faf9f7;
    --card-bg: #ffffff;
    --text: #1a202c;
    --text-light: #718096;
    --text-muted: #a0aec0;
    --border: #e2e8f0;
    --border-light: #edf2f7;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 10px 40px rgba(0, 0, 0, 0.12);
    --radius: 8px;
    --radius-lg: 12px;
}

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

body {
    font-family: 'Source Serif 4', 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.7;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

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

/* =============================================================================
   Header
   ============================================================================= */

header {
    text-align: center;
    margin-bottom: 2.5rem;
    padding-top: 1rem;
}

header h1 {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 2.5rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 0.75rem;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
}

header .header-logo {
    height: 2.5rem;
    width: auto;
    display: block;
}

header .subtitle {
    font-family: 'Inter', -apple-system, sans-serif;
    color: var(--text-light);
    font-size: 0.95rem;
    font-weight: 400;
    letter-spacing: 0.01em;
}

header .header-nav {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    margin-top: 1.25rem;
}

header .nav-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.7rem 1.5rem;
    background: var(--primary);
    color: white;
    text-decoration: none;
    border-radius: var(--radius);
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
    box-shadow: var(--shadow);
}

header .nav-link:hover {
    background: var(--primary-light);
    box-shadow: var(--shadow-lg);
    transform: translateY(-1px);
}

header .nav-link.secondary {
    background: var(--card-bg);
    color: var(--primary);
    border: 1px solid var(--border);
}

header .nav-link.secondary:hover {
    background: var(--border-light);
    border-color: var(--primary-light);
}

/* Legacy support for single search link */
header .search-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1.25rem;
    padding: 0.7rem 1.5rem;
    background: var(--primary);
    color: white;
    text-decoration: none;
    border-radius: var(--radius);
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
    box-shadow: var(--shadow);
}

header .search-link:hover {
    background: var(--primary-light);
    box-shadow: var(--shadow-lg);
    transform: translateY(-1px);
}

/* =============================================================================
   Tabs
   ============================================================================= */

.tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0;
    flex-wrap: wrap;
}

.tab {
    padding: 0.85rem 1.25rem;
    border: none;
    background: none;
    cursor: pointer;
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-light);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: all 0.2s ease;
    letter-spacing: 0.01em;
}

.tab:hover {
    color: var(--primary);
    background: rgba(45, 55, 72, 0.04);
}

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--accent);
}

/* Tab Dropdown */
.tab-dropdown {
    position: relative;
}

.dropdown-trigger {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.dropdown-trigger svg {
    transition: transform 0.2s;
}

.tab-dropdown.open .dropdown-trigger svg {
    transform: rotate(180deg);
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: var(--shadow-lg);
    min-width: 180px;
    padding: 0.5rem 0;
    z-index: 100;
    display: none;
}

.tab-dropdown.open .dropdown-menu {
    display: block;
}

.dropdown-item {
    display: block;
    width: 100%;
    padding: 0.6rem 1rem;
    border: none;
    background: none;
    text-align: left;
    font-size: 0.9rem;
    color: var(--text);
    cursor: pointer;
    transition: background 0.15s;
}

.dropdown-item:hover {
    background: var(--bg);
}

.dropdown-item.active {
    color: var(--primary);
    font-weight: 500;
}

/* =============================================================================
   Forms
   ============================================================================= */

.forms-container {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-lg);
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-light);
}

.citation-form {
    display: none;
}

.citation-form.active {
    display: block;
}

.citation-form h2 {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-light);
}

.rule-ref {
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    letter-spacing: 0.02em;
}

.form-row {
    display: grid;
    gap: 1.25rem;
    margin-bottom: 1.25rem;
}

.form-row.two-col {
    grid-template-columns: 1fr 1fr;
}

.form-row.three-col {
    grid-template-columns: 1fr 1fr 1fr;
}

@media (max-width: 600px) {
    .form-row.two-col,
    .form-row.three-col {
        grid-template-columns: 1fr;
    }
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text);
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.form-group input,
.form-group select {
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: 'Cormorant Garamond', Georgia, serif;
    transition: all 0.2s ease;
    background: #fafafa;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 3px rgba(45, 55, 72, 0.1);
}

.form-group input::placeholder {
    color: var(--text-muted);
    font-style: italic;
}

.form-group .hint {
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.35rem;
    font-style: italic;
}

.generate-btn,
.sample-btn {
    padding: 0.85rem 1.75rem;
    border: none;
    border-radius: var(--radius);
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-right: 0.75rem;
    margin-top: 1rem;
    letter-spacing: 0.02em;
}

.generate-btn {
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow);
}

.generate-btn:hover {
    background: var(--primary-light);
    box-shadow: var(--shadow-lg);
    transform: translateY(-1px);
}

/* URL Lookup Section */
.url-lookup-section {
    background: #f8fafc;
    border: 1px dashed var(--border);
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.url-input-row {
    display: flex;
    gap: 0.5rem;
}

.url-input-row input {
    flex: 1;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.95rem;
    font-family: inherit;
}

.lookup-btn {
    padding: 0.6rem 1rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: background 0.2s;
    white-space: nowrap;
}

.lookup-btn:hover {
    background: var(--primary-light);
}

.lookup-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.lookup-status {
    margin-top: 0.75rem;
    font-size: 0.9rem;
}

.lookup-status.loading {
    color: var(--text-light);
}

.lookup-status.success {
    color: #38a169;
}

.lookup-status.error {
    color: var(--accent);
}

.form-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1.25rem 0;
}

.sample-btn {
    background: transparent;
    color: var(--text-light);
    border: 1px solid var(--border);
}

.sample-btn:hover {
    background: var(--bg);
    color: var(--text);
    border-color: var(--text-muted);
}

/* Custom Select Styling */
.form-group select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%234a5568' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.5rem;
    cursor: pointer;
}

.form-group select:hover {
    border-color: var(--primary-light);
}

/* Custom Court Selector */
.court-selector-wrapper {
    position: relative;
}

.court-selector-btn {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: 'Cormorant Garamond', Georgia, serif;
    background: #fafafa;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s ease;
    text-align: left;
}

.court-selector-btn:hover {
    border-color: var(--primary-light);
    background: white;
}

.court-selector-btn.active {
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 3px rgba(45, 55, 72, 0.1);
}

.court-selector-btn .placeholder {
    color: var(--text-muted);
    font-style: italic;
}

.court-selector-btn svg {
    color: var(--text-light);
    transition: transform 0.2s ease;
}

.court-selector-btn.active svg {
    transform: rotate(180deg);
}

.court-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    z-index: 1000;
    max-height: 350px;
    overflow-y: auto;
    display: none;
}

.court-dropdown.open {
    display: block;
    animation: dropdownSlide 0.15s ease;
}

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

.court-dropdown-header {
    padding: 0.75rem 1rem;
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-light);
    background: var(--bg);
    position: sticky;
    top: 0;
}

.court-dropdown-section {
    padding: 0.5rem 0;
}

.court-dropdown-section-title {
    padding: 0.5rem 1rem;
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.court-option {
    padding: 0.65rem 1rem;
    cursor: pointer;
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1rem;
    transition: background 0.1s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.court-option:hover {
    background: var(--bg);
}

.court-option.selected {
    background: rgba(45, 55, 72, 0.08);
    color: var(--primary);
}

.court-option .court-abbrev {
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.court-custom-input {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1rem;
    transition: all 0.2s ease;
}

.court-custom-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(45, 55, 72, 0.1);
}

.court-custom-input::placeholder {
    color: var(--text-muted);
    font-style: italic;
}

/* =============================================================================
   Output Section
   ============================================================================= */

.output-section {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.output-section h3 {
    font-size: 1.1rem;
    color: var(--primary);
    margin-bottom: 1rem;
}

.context-toggle {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.context-toggle label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
}

.context-toggle input[type="radio"] {
    accent-color: var(--primary);
}

.output-box {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 1rem;
    position: relative;
}

.output-box.secondary {
    background: #fff;
    border-style: dashed;
}

.output-box.plain {
    background: #1a202c;
    border: none;
}

.output-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-light);
    margin-bottom: 0.5rem;
}

.output-box.plain .output-label {
    color: #a0aec0;
}

/* =============================================================================
   Citation Typography - THE IMPORTANT PART!
   ============================================================================= */

.citation-output {
    font-family: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
    font-size: 1.15rem;
    line-height: 1.7;
    color: var(--text);
    min-height: 1.5em;
}

.citation-output.plain-text {
    font-family: 'SF Mono', Monaco, 'Courier New', monospace;
    font-size: 0.9rem;
    color: #e2e8f0;
    word-break: break-all;
}

/* Case names, article titles, book titles - ITALICS */
.citation-output em,
.citation-output .case-name,
.citation-output .title,
.citation-output .signal,
.citation-output .history,
.formatted-citation em,
.formatted-citation .title {
    font-style: italic;
}

/* Author names, journal names, constitution - SMALL CAPS */
.citation-output .small-caps,
.formatted-citation .small-caps {
    font-variant: small-caps;
    font-weight: 600;
    letter-spacing: 0.02em;
}

/* URLs */
.citation-output .url {
    font-family: 'SF Mono', Monaco, 'Courier New', monospace;
    font-size: 0.85em;
    color: var(--primary-light);
    word-break: break-all;
}

/* Empty state */
.citation-output:empty::before {
    content: 'Your citation will appear here...';
    color: #a0aec0;
    font-style: italic;
}

/* Copy button */
.copy-btn {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #a0aec0;
    padding: 0.4rem 0.75rem;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: all 0.2s;
}

.copy-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.copy-btn.copied {
    background: #48bb78;
    border-color: #48bb78;
    color: white;
}

/* =============================================================================
   Validation Issues
   ============================================================================= */

.validation-issues {
    background: #fff5f5;
    border: 1px solid #feb2b2;
    border-radius: 6px;
    padding: 1rem;
    margin-top: 1rem;
}

.validation-issues .output-label {
    color: var(--accent);
}

.validation-issues ul {
    list-style: none;
    font-size: 0.9rem;
}

.validation-issues li {
    padding: 0.25rem 0;
    color: #c53030;
}

.validation-issues li::before {
    content: '⚠ ';
}

/* =============================================================================
   Footer
   ============================================================================= */

footer {
    text-align: center;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

footer p {
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.85rem;
    color: var(--text-light);
    margin-bottom: 0.35rem;
}

footer .disclaimer {
    font-size: 0.8rem;
}

footer .copyright {
    font-size: 0.8rem;
    margin-top: 0.5rem;
}

footer a {
    color: var(--text-light);
    text-decoration: none;
    transition: color 0.2s ease;
}

footer a:hover {
    color: var(--primary);
}

/* =============================================================================
   Print Styles
   ============================================================================= */

@media print {
    .tabs,
    .forms-container,
    .context-toggle,
    .copy-btn,
    footer {
        display: none;
    }

    .output-section {
        box-shadow: none;
        padding: 0;
    }

    .citation-output {
        font-size: 12pt;
    }
}
