/* ===========================
   AMRI Management - Modern Admin Layout
   =========================== */

:root {
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 72px;
    --topbar-height: 60px;
    --sidebar-bg: #1e293b;
    --sidebar-hover: #334155;
    --sidebar-active: #3b82f6;
    --sidebar-text: #94a3b8;
    --sidebar-text-active: #ffffff;
    --sidebar-brand: #ffffff;
    --topbar-bg: #ffffff;
    --content-bg: #f1f5f9;
    --transition-speed: 0.25s;
}

/* Base */
html {
    font-size: 14px;
    position: relative;
    min-height: 100%;
}

@media (min-width: 768px) {
    html { font-size: 15px; }
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--content-bg);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    overflow-x: hidden;
}

/* ===========================
   Sidebar
   =========================== */

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: width var(--transition-speed) ease, transform var(--transition-speed) ease;
    overflow: hidden;
}

.sidebar-brand {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}

.sidebar-brand a {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--sidebar-brand);
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-brand i {
    font-size: 1.5rem;
    color: var(--sidebar-active);
    flex-shrink: 0;
    width: 32px;
    text-align: center;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
}

.nav-section-label {
    padding: 20px 20px 8px 20px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: rgba(148, 163, 184, 0.6);
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    margin: 2px 10px;
    border-radius: 8px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    transition: all 0.15s ease;
}

.sidebar-link i {
    font-size: 1.15rem;
    width: 32px;
    text-align: center;
    flex-shrink: 0;
    transition: color 0.15s ease;
}

.sidebar-link:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text-active);
    text-decoration: none;
}

.sidebar-link.active {
    background: var(--sidebar-active);
    color: var(--sidebar-text-active);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.35);
}

.sidebar-link.active i {
    color: var(--sidebar-text-active);
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.08);
    color: rgba(148, 163, 184, 0.5);
    font-size: 0.75rem;
    flex-shrink: 0;
    white-space: nowrap;
    overflow: hidden;
}

/* ===========================
   Top Bar
   =========================== */

.topbar {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    height: var(--topbar-height);
    background: var(--topbar-bg);
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 1030;
    transition: left var(--transition-speed) ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-title {
    font-size: 1.15rem;
    font-weight: 600;
    color: #1e293b;
    margin: 0;
    white-space: nowrap;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.sidebar-toggle {
    background: none;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 1.3rem;
    color: #475569;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: all 0.15s ease;
}

.sidebar-toggle:hover {
    background: #f1f5f9;
    color: #1e293b;
}

/* ===========================
   Main Content
   =========================== */

.main-wrapper {
    margin-left: var(--sidebar-width);
    padding-top: var(--topbar-height);
    min-height: 100vh;
    transition: margin-left var(--transition-speed) ease;
}

.main-content {
    padding: 28px 32px;
}

/* ===========================
   Sidebar Collapsed State
   =========================== */

.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed-width);
}

.sidebar-collapsed .sidebar .brand-text,
.sidebar-collapsed .sidebar .sidebar-link span,
.sidebar-collapsed .sidebar .nav-section-label,
.sidebar-collapsed .sidebar .sidebar-footer small {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, visibility 0.15s ease;
}

.sidebar-collapsed .sidebar .sidebar-link {
    justify-content: center;
    padding: 10px;
    margin: 2px 8px;
}

.sidebar-collapsed .sidebar .sidebar-link i {
    margin: 0;
}

.sidebar-collapsed .sidebar .sidebar-brand {
    justify-content: center;
    padding: 0;
}

.sidebar-collapsed .sidebar .sidebar-brand a {
    justify-content: center;
}

.sidebar-collapsed .topbar {
    left: var(--sidebar-collapsed-width);
}

.sidebar-collapsed .main-wrapper {
    margin-left: var(--sidebar-collapsed-width);
}

/* Tooltip on collapsed sidebar */
.sidebar-collapsed .sidebar .sidebar-link {
    position: relative;
}

.sidebar-collapsed .sidebar .sidebar-link:hover::after {
    content: attr(data-title);
    position: absolute;
    left: calc(100% + 8px);
    top: 50%;
    transform: translateY(-50%);
    background: #1e293b;
    color: #fff;
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    white-space: nowrap;
    z-index: 1050;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    pointer-events: none;
}

/* ===========================
   Kongress Year Selector (Topbar)
   =========================== */

.kongressjahr-selector {
    display: flex;
    align-items: center;
    gap: 8px;
}

.kongressjahr-selector label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #64748b;
    margin: 0;
    white-space: nowrap;
}

.kongressjahr-selector select {
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    padding: 4px 28px 4px 10px;
    font-size: 0.85rem;
    font-weight: 500;
    color: #334155;
    background-color: #f8fafc;
    transition: border-color 0.15s;
}

.kongressjahr-selector select:focus {
    border-color: var(--sidebar-active);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* ===========================
   Login Partial (Topbar)
   =========================== */

.user-menu {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-left: 16px;
    border-left: 1px solid #e2e8f0;
}

.user-menu .user-greeting {
    font-size: 0.85rem;
    font-weight: 500;
    color: #475569;
}

.user-menu .user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 600;
}

.user-menu .btn-logout {
    background: none;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 5px 14px;
    font-size: 0.8rem;
    font-weight: 500;
    color: #64748b;
    cursor: pointer;
    transition: all 0.15s ease;
}

.user-menu .btn-logout:hover {
    background: #fef2f2;
    border-color: #fecaca;
    color: #dc2626;
}

/* ===========================
   Auth Layout (not logged in)
   =========================== */

.auth-layout {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--content-bg);
}

/* ===========================
   Responsive
   =========================== */

@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width);
    }

    body:not(.sidebar-collapsed) .sidebar {
        transform: translateX(0);
    }

    .sidebar-collapsed .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width);
    }

    .topbar {
        left: 0;
    }

    .main-wrapper {
        margin-left: 0;
    }

    .sidebar-collapsed .topbar {
        left: 0;
    }

    .sidebar-collapsed .main-wrapper {
        margin-left: 0;
    }

    /* Overlay when sidebar open on mobile */
    body:not(.sidebar-collapsed)::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.4);
        z-index: 1035;
    }

    .main-content {
        padding: 20px 16px;
    }
}

@media (max-width: 575.98px) {
    .topbar-title {
        display: none;
    }

    .topbar {
        padding: 0 12px;
    }

    .topbar-right {
        gap: 8px;
    }

    .user-menu .user-greeting {
        display: none;
    }
}

/* ===========================
   Existing Utility Styles
   =========================== */

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

.form-floating > .form-control-plaintext::placeholder,
.form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder,
.form-floating > .form-control:focus::placeholder {
    text-align: start;
}

.log-file-btn.active {
    background-color: #0d6efd;
    color: white;
}

.log-file-btn:hover {
    background-color: #f8f9fa;
}

.log-file-btn.active:hover {
    background-color: #0b5ed7;
    color: white;
}

#loadingIndicator {
    padding: 20px;
}

.table td {
    max-width: 500px;
    overflow-wrap: break-word;
}

/* ===========================
   Card & Table Enhancements
   =========================== */

.card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid #f1f5f9;
    font-weight: 600;
}

.table {
    font-size: 0.9rem;
}

.table thead th {
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #64748b;
    border-bottom-width: 1px;
}

/* ===========================
   Better Buttons
   =========================== */

.btn {
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.875rem;
    padding: 0.45rem 1rem;
}

.btn-primary {
    background: #3b82f6;
    border-color: #3b82f6;
}

.btn-primary:hover {
    background: #2563eb;
    border-color: #2563eb;
}

/* ===========================
   Scrollbar (Global)
   =========================== */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}
