/* ============================================
   Components CSS — Sidebar, Topbar, Modals, Toasts
   ============================================ */

/* ---- Sidebar ---- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: linear-gradient(180deg, #1a1f2e 0%, #151922 100%);
    color: #c4c8d4;
    display: flex;
    flex-direction: column;
    z-index: 1050;
    transition: transform var(--transition-normal);
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: 2px 0 12px rgba(0,0,0,0.15);
}

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

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-logo i {
    font-size: 1.75rem;
    color: var(--primary);
    filter: drop-shadow(0 0 8px rgba(0,120,212,0.3));
}

.sidebar-brand {
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.3px;
}

.btn-sidebar-close {
    background: none;
    border: none;
    color: #8a8f9e;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 4px;
}

/* Sidebar User */
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    margin: 0.5rem 0.75rem;
    background: rgba(255,255,255,0.04);
    border-radius: var(--radius-md);
}

.sidebar-avatar i {
    font-size: 2rem;
    color: var(--primary);
}

.sidebar-user-name {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: #e1e4ea;
}

.sidebar-user-role {
    display: block;
    font-size: 0.75rem;
    color: #8a8f9e;
    text-transform: capitalize;
}

/* Sidebar Nav */
.sidebar-nav {
    flex: 1;
    padding: 0.5rem 0;
    overflow-y: auto;
}

.nav-section {
    margin-bottom: 0.5rem;
}

.nav-section-title {
    display: block;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: #5a5f70;
    padding: 0.75rem 1.25rem 0.35rem;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1.25rem;
    color: #9a9fae;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 0;
    transition: all var(--transition-fast);
    border-left: 3px solid transparent;
    position: relative;
}

.sidebar-nav .nav-link i {
    font-size: 1.1rem;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-nav .nav-link:hover {
    color: #e1e4ea;
    background: rgba(255,255,255,0.06);
}

.sidebar-nav .nav-link.active {
    color: #fff;
    background: rgba(0, 120, 212, 0.15);
    border-left-color: var(--primary);
}

.sidebar-nav .nav-link.active i {
    color: var(--primary);
}

/* Sidebar Footer */
.sidebar-footer {
    border-top: 1px solid rgba(255,255,255,0.06);
    padding: 0.5rem 0;
}

.sidebar-footer .nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1.25rem;
    color: #9a9fae;
    font-size: 0.875rem;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.sidebar-footer .nav-link:hover {
    color: #e1e4ea;
    background: rgba(255,255,255,0.06);
}

.sidebar-footer .btn-logout:hover {
    color: var(--danger);
}

.sidebar-footer .nav-link i {
    font-size: 1.1rem;
    width: 22px;
    text-align: center;
}

/* 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: 1040;
    backdrop-filter: blur(2px);
}

.sidebar-overlay.show {
    display: block;
    animation: fadeIn var(--transition-fast) ease;
}

/* ---- Topbar ---- */
.topbar {
    position: fixed;
    top: 0;
    right: 0;
    left: var(--sidebar-width);
    height: var(--topbar-height);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    z-index: 1030;
    transition: left var(--transition-normal);
    box-shadow: var(--shadow-xs);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.btn-sidebar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
}

.topbar-title {
    font-size: 1.15rem;
    font-weight: 600;
    margin: 0;
    color: var(--text-primary);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Topbar Search */
.topbar-search {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--gray-100);
    border-radius: var(--radius-md);
    padding: 0 0.75rem;
    transition: all var(--transition-fast);
    border: 1px solid transparent;
}

.topbar-search:focus-within {
    background: var(--surface);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-alpha);
}

.topbar-search i {
    color: var(--text-tertiary);
    font-size: 0.9rem;
}

.topbar-search input {
    border: none;
    background: none;
    padding: 0.5rem 0.5rem;
    font-size: 0.875rem;
    color: var(--text-primary);
    width: 180px;
    outline: none;
}

.topbar-search input::placeholder {
    color: var(--text-tertiary);
}

/* Search Results Dropdown */
.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    margin-top: 4px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1060;
}

.search-result-item {
    padding: 0.65rem 0.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--divider);
    transition: background var(--transition-fast);
}

.search-result-item:hover {
    background: var(--primary-alpha);
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item i {
    color: var(--primary);
    font-size: 1rem;
}

/* Notifications Button */
.btn-notification {
    position: relative;
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.btn-notification:hover {
    background: var(--gray-100);
    color: var(--primary);
}

.notification-badge {
    position: absolute;
    top: 0;
    right: 0;
    background: var(--danger);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    animation: badgePop 0.3s ease;
}

@keyframes badgePop {
    0% { transform: scale(0); }
    70% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* Topbar User */
.topbar-user {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
}

.topbar-user:hover {
    background: var(--gray-100);
}

.topbar-user-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
}

.topbar-avatar {
    font-size: 1.5rem;
    color: var(--primary);
}

/* ---- Notification Panel ---- */
.notification-panel {
    position: fixed;
    top: var(--topbar-height);
    right: 1rem;
    width: 380px;
    max-height: 500px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    z-index: 1060;
    overflow: hidden;
    animation: slideDown 0.2s ease;
}

.notification-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid var(--divider);
}

.notification-panel-header h5 {
    margin: 0;
    font-size: 1rem;
}

.notification-panel-body {
    max-height: 400px;
    overflow-y: auto;
}

.notification-item {
    display: flex;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--divider);
    font-size: 0.85rem;
    transition: background var(--transition-fast);
}

.notification-item:hover {
    background: var(--gray-50);
}

.notification-item i {
    font-size: 1.1rem;
    flex-shrink: 0;
    margin-top: 2px;
}

.notification-item.warning i { color: var(--warning); }
.notification-item.danger i { color: var(--danger); }
.notification-item.info i { color: var(--info); }

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

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ---- Toast ---- */
.toast-custom {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    border-left: 4px solid var(--primary);
    animation: toastIn 0.3s ease;
}

.toast-custom.toast-success { border-left-color: var(--success); }
.toast-custom.toast-error { border-left-color: var(--danger); }
.toast-custom.toast-warning { border-left-color: var(--warning); }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(100%); }
    to { opacity: 1; transform: translateX(0); }
}

/* ---- Camera ---- */
.camera-container {
    width: 100%;
    min-height: 300px;
    background: #000;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.camera-container video,
.camera-container img {
    width: 100%;
    max-height: 70vh;
    object-fit: contain;
}

/* ---- Responsive ---- */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.show {
        transform: translateX(0);
    }
    
    .topbar {
        left: 0;
    }
    
    .btn-sidebar-toggle {
        display: block;
    }
    
    .topbar-search {
        display: none;
    }
    
    .topbar-user-name {
        display: none;
    }
    
    .notification-panel {
        width: calc(100% - 2rem);
        right: 1rem;
        left: 1rem;
    }
}

@media (max-width: 575.98px) {
    .topbar {
        padding: 0 1rem;
    }
    
    .topbar-title {
        font-size: 1rem;
    }
}
