/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --secondary-color: #8b5cf6;
    --success-color: #10b981;
    --error-color: #ef4444;
    --bg-color: #0f172a;
    --bg-light: #1e293b;
    --bg-lighter: #334155;
    --text-color: #f1f5f9;
    --text-muted: #94a3b8;
    --border-color: #475569;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: var(--text-color);
    min-height: 100vh;
    line-height: 1.6;
}

/* ========== LOGIN PAGE ========== */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-container {
    width: 100%;
    max-width: 400px;
}

.login-box {
    background: var(--bg-light);
    border-radius: 16px;
    padding: 40px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header h1 {
    font-size: 28px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}

.login-header p {
    color: var(--text-muted);
    font-size: 14px;
}

.error-message {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--error-color);
    color: var(--error-color);
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
    text-align: center;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

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

.form-group label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
}

.form-group input {
    padding: 12px 16px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-color);
    font-size: 14px;
    transition: all 0.3s ease;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.btn-login {
    padding: 12px 24px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    margin-top: 10px;
}

.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(99, 102, 241, 0.3);
}

.btn-login:active {
    transform: translateY(0);
}

.login-footer {
    text-align: center;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

.login-footer p {
    color: var(--text-muted);
    font-size: 12px;
}

/* ========== MAIN APPLICATION ========== */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    background: var(--bg-light);
    border-radius: 16px;
    padding: 24px 32px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.header h1 {
    font-size: 28px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 20px;
}

.user-info {
    color: var(--text-muted);
    font-size: 14px;
}

.user-info strong {
    color: var(--text-color);
}

.btn-logout {
    padding: 8px 20px;
    background: rgba(239, 68, 68, 0.1);
    color: var(--error-color);
    text-decoration: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    border: 1px solid var(--error-color);
    transition: all 0.3s ease;
}

.btn-logout:hover {
    background: var(--error-color);
    color: white;
}

/* Search Section */
.search-section {
    margin-bottom: 24px;
}

.search-box {
    background: var(--bg-light);
    border-radius: 16px;
    padding: 32px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

.search-box h2 {
    font-size: 20px;
    margin-bottom: 20px;
    color: var(--text-color);
}

.search-form {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.search-form input {
    flex: 1;
    min-width: 250px;
    padding: 14px 20px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-color);
    font-size: 16px;
    transition: all 0.3s ease;
}

.search-form input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.btn-search {
    padding: 14px 32px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-search:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(99, 102, 241, 0.3);
}

.btn-search:active {
    transform: translateY(0);
}

/* Results Section */
.results-section {
    background: var(--bg-light);
    border-radius: 16px;
    padding: 32px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.results-header h2 {
    font-size: 22px;
    color: var(--text-color);
}

.results-header h2 span {
    color: var(--primary-color);
}

.results-info {
    display: flex;
    gap: 20px;
    color: var(--text-muted);
    font-size: 14px;
}

/* Filters */
.filters {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.filters input {
    flex: 1;
    min-width: 200px;
    padding: 10px 16px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-color);
    font-size: 14px;
    transition: all 0.3s ease;
}

.filters input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Loading Spinner */
.loading {
    text-align: center;
    padding: 40px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

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

.loading p {
    color: var(--text-muted);
}

/* Error Box */
.error-box {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--error-color);
    color: var(--error-color);
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    text-align: center;
}

/* Chat Table */
.table-container {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.chat-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.chat-table thead {
    background: var(--bg-color);
}

.chat-table th {
    padding: 16px;
    text-align: left;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.chat-table tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.2s ease;
}

.chat-table tbody tr:hover {
    background: rgba(99, 102, 241, 0.05);
}

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

.chat-table td {
    padding: 16px;
    color: var(--text-color);
}

.chat-table td:nth-child(1) {
    color: var(--text-muted);
    font-family: 'Courier New', monospace;
}

.chat-table td:nth-child(2) {
    color: var(--primary-color);
    font-weight: 500;
}

.chat-table td:nth-child(3) {
    color: var(--secondary-color);
    font-size: 13px;
}

.chat-table td:nth-child(4) {
    color: var(--text-muted);
    font-size: 13px;
    white-space: nowrap;
}

.chat-table td:nth-child(5) {
    max-width: 500px;
    word-wrap: break-word;
}

/* No Results */
.no-results {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.no-results p {
    font-size: 16px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        align-items: flex-start;
    }

    .header-actions {
        width: 100%;
        justify-content: space-between;
    }

    .search-form {
        flex-direction: column;
    }

    .search-form input,
    .btn-search {
        width: 100%;
    }

    .filters {
        flex-direction: column;
    }

    .table-container {
        font-size: 12px;
    }

    .chat-table th,
    .chat-table td {
        padding: 10px 8px;
    }
}