/* CSS Custom Properties - Young Estates Inspired */
:root {
    --primary-blue: #2c5aa0;
    --primary-dark: #1a3d73;
    --primary-light: #4a7bc8;
    --white: #ffffff;
    --light-grey: #f8f9fa;
    --medium-grey: #6c757d;
    --dark-grey: #343a40;
    --border-grey: #dee2e6;
    --success-green: #28a745;
    --warning-orange: #fd7e14;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-accent: #e9ecef;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-primary);
    font-weight: 400;
    letter-spacing: -0.01em;
    background-color: var(--bg-secondary);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 clamp(1rem, 4vw, 2rem);
}

header {
    text-align: center;
    margin-bottom: 2rem;
    padding: clamp(2rem, 6vw, 4rem) 0;
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--primary-dark) 100%);
    color: white;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    position: relative;
    overflow: hidden;
}

header h1 {
    font-size: clamp(2rem, 4vw, 3rem);
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.02em;
    margin-bottom: 0.5rem;
    position: relative;
    z-index: 1;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

header p {
    font-size: 1.125rem;
    font-weight: 400;
    line-height: 1.6;
    opacity: 0.95;
    position: relative;
    z-index: 1;
    color: white;
    margin-bottom: 0;
}

.search-form {
    background: var(--bg-primary);
    padding: clamp(2rem, 5vw, 3rem);
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    border: 1px solid var(--border-grey);
    margin-bottom: 2rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

input[type="text"],
input[type="number"],
input[type="password"] {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 2px solid var(--border-grey);
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.2s ease;
    background: var(--bg-primary);
    color: var(--text-primary);
}

input:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(44, 90, 160, 0.1);
}

fieldset {
    border: 1px solid var(--border-grey);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    background: var(--bg-secondary);
    transition: all 0.2s ease;
}

legend {
    padding: 0 1rem;
    font-weight: 600;
    color: var(--primary-blue);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-top: 2rem;
    flex-wrap: wrap;
}

button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.875rem 2rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
    text-decoration: none;
}

button[type="submit"] {
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(44, 90, 160, 0.3);
    min-width: 140px;
}

button[type="button"] {
    background: var(--bg-primary);
    color: var(--primary-blue);
    border: 2px solid var(--primary-blue);
}

.spinner {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid #ffffff40;
    border-top: 2px solid #ffffff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 8px;
}

.loading .btn-text { display: none; }
.loading .spinner { display: inline-block; }

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

.error-message {
    color: var(--warning-orange);
    font-size: 0.875rem;
    margin-top: 0.25rem;
    display: block;
    font-weight: 500;
}

.main-error {
    margin-top: 1rem;
    padding: 1rem;
    background: linear-gradient(135deg, rgba(253, 126, 20, 0.1) 0%, rgba(253, 126, 20, 0.05) 100%);
    border: 1px solid rgba(253, 126, 20, 0.3);
    border-radius: 8px;
    display: none;
    color: var(--warning-orange);
    font-weight: 500;
}

.main-error.show { display: block; }

.hidden { display: none !important; }

/* Results Section - Modern Card Design */
.results-section {
    background: var(--bg-primary);
    border-radius: 12px;
    box-shadow: 
        0 8px 16px -4px rgba(0, 0, 0, 0.1),
        0 4px 8px -2px rgba(0, 0, 0, 0.06);
    border: 2px solid var(--border-grey);
    overflow: hidden;
    transition: all 0.3s ease;
    margin-top: 2rem;
    margin-bottom: 2rem;
}

.results-section:hover {
    box-shadow: 
        0 12px 20px -4px rgba(0, 0, 0, 0.15),
        0 6px 12px -2px rgba(0, 0, 0, 0.08);
    border-color: var(--primary-light);
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-grey);
}

.results-header h2 {
    font-size: clamp(1.25rem, 3vw, 1.5rem);
    font-weight: 600;
    color: var(--primary-blue);
    margin-bottom: 0;
}

.results-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

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

.export-btn {
    background: linear-gradient(135deg, var(--success-green) 0%, #218838 100%);
    color: white;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    border-radius: 6px;
    font-weight: 500;
    box-shadow: 0 2px 6px rgba(40, 167, 69, 0.3);
}

.export-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.4);
}

/* Table - Enhanced with better formatting */
.table-container {
    overflow-x: auto;
    border: 2px solid var(--border-grey);
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    background: var(--bg-primary);
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    min-width: 1000px;
}

.results-table th,
.results-table td {
    padding: 1rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-grey);
    border-right: 1px solid var(--border-grey);
    vertical-align: top;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 250px;
}

.results-table th:last-child,
.results-table td:last-child {
    border-right: none;
}

.results-table th {
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-accent) 100%);
    font-weight: 600;
    color: var(--text-primary);
    position: sticky;
    top: 0;
    z-index: 10;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 2px solid var(--primary-blue);
}

.sortable {
    cursor: pointer;
    position: relative;
    user-select: none;
    transition: all 0.2s ease;
}

.sortable:hover {
    background: var(--bg-accent);
    color: var(--primary-blue);
}

.sort-indicator {
    margin-left: 8px;
    opacity: 0.5;
    font-weight: normal;
}

.sort-indicator:after {
    content: '↕';
}

.sortable.asc .sort-indicator:after {
    content: '↑';
    opacity: 1;
    color: var(--primary-blue);
}

.sortable.desc .sort-indicator:after {
    content: '↓';
    opacity: 1;
    color: var(--primary-blue);
}

.results-table tbody tr {
    transition: all 0.2s ease;
    border-bottom: 1px solid var(--border-grey);
}

.results-table tbody tr:hover {
    background: linear-gradient(135deg, rgba(44, 90, 160, 0.05) 0%, rgba(26, 61, 115, 0.05) 100%);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.results-table tbody tr:last-child {
    border-bottom: none;
}

/* Cell-specific styling */
.tro-name-cell {
    font-weight: 500;
    color: var(--primary-blue);
    max-width: 300px;
}

.date-cell {
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    white-space: nowrap;
    min-width: 140px;
}

.creator-cell {
    font-weight: 500;
    text-align: center;
    min-width: 80px;
}

.regulation-cell {
    max-width: 200px;
}

.id-cell {
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
    color: var(--text-secondary);
    max-width: 200px;
    word-break: break-all;
}

.regulation-type {
    background: linear-gradient(135deg, rgba(44, 90, 160, 0.1) 0%, rgba(26, 61, 115, 0.1) 100%);
    color: var(--primary-blue);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    display: inline-block;
    margin: 0.1rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    border: 1px solid rgba(44, 90, 160, 0.2);
}

/* Pagination - Professional Design */
.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-grey);
    flex-wrap: wrap;
    gap: 1rem;
}

.pagination-info {
    flex-basis: 100%;
    text-align: center;
    margin-top: 0.5rem;
}

.pagination-info small {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.page-btn {
    background: var(--bg-primary);
    color: var(--primary-blue);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    border: 2px solid var(--primary-blue);
    font-weight: 500;
}

.page-btn:hover:not(:disabled) {
    background: var(--primary-blue);
    color: white;
    transform: translateY(-1px);
}

.page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    border-color: var(--medium-grey);
    color: var(--medium-grey);
}

#pageInfo {
    font-weight: 500;
    color: var(--text-primary);
}

/* No Results - Professional Styling */
.no-results {
    text-align: center;
    padding: 3rem;
    background: var(--bg-primary);
    border-radius: 12px;
    box-shadow: 
        0 4px 6px -1px rgba(0, 0, 0, 0.1),
        0 2px 4px -1px rgba(0, 0, 0, 0.06);
    border: 1px solid var(--border-grey);
}

.no-results h3 {
    color: var(--primary-blue);
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.no-results p {
    color: var(--text-secondary);
    margin-bottom: 0;
}