/* === Reset & Base === */
*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: #f4f6f9;
}

/* === App Wrapper === */
.app-wrapper {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* === Sidebar === */
.sidebar {
    width: 250px;
    min-width: 250px;
    background: linear-gradient(180deg, #1e2a3a 0%, #15202b 100%);
    color: #c8d6e5;
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease, min-width 0.3s ease;
    z-index: 1000;
    overflow: hidden;
}

.sidebar.collapsed {
    width: 60px;
    min-width: 60px;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand {
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-brand i {
    font-size: 1.4rem;
    color: #4fc3f7;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: #c8d6e5;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: transform 0.3s ease;
}

.sidebar.collapsed .sidebar-toggle {
    transform: rotate(180deg);
}

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
}

.sidebar-nav .nav-link {
    color: #c8d6e5;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    transition: all 0.2s;
    border-left: 3px solid transparent;
    white-space: nowrap;
}

.sidebar-nav .nav-link:hover,
.sidebar-nav .nav-link:focus {
    background: rgba(255,255,255,0.08);
    color: #fff;
}

.sidebar-nav .nav-link.active {
    background: rgba(79, 195, 247, 0.15);
    color: #4fc3f7;
    border-left-color: #4fc3f7;
}

.sidebar-nav .nav-link i {
    font-size: 1.3rem;
    min-width: 24px;
    text-align: center;
}

.sidebar-text {
    opacity: 1;
    transition: opacity 0.2s ease;
}

.sidebar.collapsed .sidebar-text,
.sidebar.collapsed .sidebar-footer,
.sidebar.collapsed .sidebar-brand span {
    opacity: 0;
    width: 0;
    overflow: hidden;
    display: inline-block;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,0.08);
    color: #6c7a8d;
}

/* === Main Area === */
.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

/* === Topbar === */
.topbar {
    background: #fff;
    border-bottom: 1px solid #e9ecef;
    padding: 8px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 52px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-clock {
    font-size: 0.9rem;
    color: #495057;
    display: flex;
    align-items: center;
    gap: 4px;
}

.topbar-clock i {
    color: #6c757d;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-user {
    font-weight: 500;
    color: #495057;
    display: flex;
    align-items: center;
    gap: 6px;
}

.topbar-user i {
    font-size: 1.2rem;
    color: #6c757d;
}

.topbar-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: #28a745;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #28a745;
    border-radius: 50%;
    display: inline-block;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* === Content === */
.content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: #f4f6f9;
}

/* === Login Page === */
.login-page {
    background: linear-gradient(135deg, #1e2a3a 0%, #2c3e50 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.login-container {
    width: 100%;
    max-width: 420px;
    padding: 20px;
}

.login-card {
    background: #fff;
    border-radius: 12px;
    padding: 40px 32px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
    color: #1e2a3a;
}

.login-header i {
    color: #4fc3f7;
}

/* === Cards === */
.card {
    border-radius: 8px;
    transition: box-shadow 0.2s;
}

.card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.card-header {
    border-bottom: 1px solid #f0f0f0;
    font-weight: 600;
}

/* === Tables === */
.table th {
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.table-hover tbody tr:hover {
    background-color: rgba(79, 195, 247, 0.04);
}

/* === Pagination === */
.pagination {
    margin: 16px 0;
}

.page-link {
    border: none;
    color: #495057;
    padding: 6px 12px;
    border-radius: 4px;
    margin: 0 2px;
}

.page-item.active .page-link {
    background: #1e2a3a;
    color: #fff;
}

/* === Sidebar Overlay (mobile) === */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 999;
}

#sidebarCheckbox:checked ~ .sidebar-overlay {
    display: block;
}

/* === Responsive === */
@media (max-width: 991.98px) {
    .sidebar {
        position: fixed;
        left: -260px;
        top: 0;
        height: 100%;
        transition: left 0.3s ease;
        width: 250px;
        min-width: 250px;
    }

    #sidebarCheckbox:checked ~ .app-wrapper .sidebar {
        left: 0;
    }

    .sidebar.collapsed {
        width: 250px;
        min-width: 250px;
    }

    #sidebarCheckbox:checked ~ .app-wrapper .sidebar.collapsed .sidebar-text,
    #sidebarCheckbox:checked ~ .app-wrapper .sidebar.collapsed .sidebar-footer,
    #sidebarCheckbox:checked ~ .app-wrapper .sidebar.collapsed .sidebar-brand span {
        opacity: 1;
        width: auto;
        display: inline-block;
    }
}

/* === Misc === */
.badge {
    font-weight: 500;
    padding: 6px 10px;
}

.btn {
    border-radius: 6px;
    font-weight: 500;
}

.form-control, .form-select {
    border-radius: 6px;
    border-color: #dee2e6;
}

.form-control:focus, .form-select:focus {
    border-color: #4fc3f7;
    box-shadow: 0 0 0 0.2rem rgba(79, 195, 247, 0.15);
}

/* === Modal === */
.modal-content {
    border: none;
    border-radius: 12px;
}

.modal-header {
    border-bottom: 1px solid #f0f0f0;
}

.modal-footer {
    border-top: 1px solid #f0f0f0;
}

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

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #c8d6e5;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a0b0c0;
}

/* === Chat === */
#chat-working { display: none; }
.chat-card {
    border-radius: 10px;
    overflow: hidden;
}

.chat-messages {
    background: #f8f9fb;
}

.chat-message {
    max-width: 80%;
}

.chat-message-user {
    margin-left: auto;
}

.chat-message-user .chat-bubble {
    background: #1e2a3a;
    color: #fff;
    border-radius: 16px 16px 4px 16px;
}

.chat-message-user .chat-role {
    color: rgba(255,255,255,0.6) !important;
}

.chat-message-assistant {
    margin-right: auto;
}

.chat-message-assistant .chat-bubble {
    background: #fff;
    color: #212529;
    border: 1px solid #e9ecef;
    border-radius: 16px 16px 16px 4px;
}

.chat-bubble {
    padding: 12px 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.chat-content {
    line-height: 1.6;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.chat-card .card-footer {
    background: #fff;
}

#chat-input {
    border-radius: 8px;
    border: 2px solid #e9ecef;
    padding: 10px 16px;
    font-size: 0.95rem;
}

#chat-input:focus {
    border-color: #4fc3f7;
    box-shadow: 0 0 0 0.2rem rgba(79, 195, 247, 0.1);
}

.chat-card .btn-primary {
    border-radius: 8px;
}

/* === Topbar News === */
.topbar-news {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 300px;
}

/* chat message code blocks */
.chat-content pre {
    background: rgba(0,0,0,0.05);
    border-radius: 6px;
    padding: 10px;
    overflow-x: auto;
    font-size: 0.85rem;
}

.chat-message-user .chat-content pre {
    background: rgba(255,255,255,0.1);
}

/* === Column Resize === */
.resize-col {
    position: relative;
    overflow: visible;
}
.col-resize-handle {
    position: absolute;
    top: 0;
    right: 0;
    width: 5px;
    height: 100%;
    cursor: col-resize;
    z-index: 10;
}
.col-resize-handle:hover {
    background: rgba(79, 195, 247, 0.4);
}

/* === Filter Inputs === */
.filter-row input {
    font-size: 0.8rem;
    border-radius: 4px;
    border: 1px solid #dee2e6;
    padding: 2px 6px;
    min-width: 60px;
}
.filter-row input:focus {
    border-color: #4fc3f7;
    box-shadow: 0 0 0 0.15rem rgba(79, 195, 247, 0.15);
}
