/* ===== LabelFlow - Custom Stylesheet ===== */

:root {
    --sidebar-width: 260px;
    --topbar-height: 56px;
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --surface: #1a1b2e;
    --surface-light: #242540;
    --surface-hover: #2d2e4a;
    --border: rgba(255, 255, 255, 0.08);
    --text-primary: #e2e8f0;
    --text-muted: #94a3b8;
    --accent-gradient: linear-gradient(135deg, #6366f1, #8b5cf6, #a78bfa);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

body {
    background: #0f1017;
    color: var(--text-primary);
    overflow-x: hidden;
}

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

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

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* ===== App Layout ===== */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: transform var(--transition);
}

.sidebar-header {
    height: var(--topbar-height);
    padding: 0 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-sizing: border-box;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 1.2rem;
}

.sidebar-brand i {
    font-size: 1.5rem;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

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

.nav-section {
    margin-bottom: 0.75rem;
    padding: 0 0.75rem;
}

.nav-section-title {
    display: block;
    padding: 0.25rem 0.75rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.05em;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all var(--transition);
    margin-bottom: 2px;
}

.sidebar-nav .nav-link:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.sidebar-nav .nav-link.active {
    background: rgba(99, 102, 241, 0.15);
    color: #a5b4fc;
}

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

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

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent-gradient);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    flex-shrink: 0;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 600;
    font-size: 0.85rem;
}

.user-role {
    font-size: 0.7rem;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.25rem;
}

/* Mobile sidebar */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1039;
    backdrop-filter: blur(4px);
}

.sidebar-overlay.active {
    display: block;
}

/* ===== Main Content ===== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

@media (max-width: 991.98px) {
    .main-content {
        margin-left: 0;
    }
}

/* ===== Topbar ===== */
.topbar {
    position: sticky;
    top: 0;
    z-index: 1020;
    min-height: var(--topbar-height);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: rgba(15, 16, 23, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}

.topbar-title {
    flex: 1;
    min-width: 0;
}

.topbar-title h1 {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-actions {
    flex-shrink: 0;
}

/* ===== Content ===== */
.content-wrapper {
    flex: 1;
    padding: 1.5rem;
    width: 100%;
}

@media (max-width: 767.98px) {
    .topbar {
        padding: 0 1rem;
    }

    .topbar-title h1 {
        font-size: 0.95rem;
    }

    .content-wrapper {
        padding: 1rem;
    }
}

/* ===== Auth Pages ===== */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: radial-gradient(ellipse at top, #1a1b3a 0%, #0f1017 70%);
}

.auth-alerts {
    width: 100%;
    max-width: 420px;
    margin-bottom: 1rem;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2.5rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-logo {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    font-size: 1.75rem;
    color: white;
}

.auth-header h2 {
    font-weight: 700;
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

/* ===== Cards ===== */
.card {
    background: var(--surface);
    border-color: var(--border);
    border-radius: var(--radius);
    transition: transform var(--transition), box-shadow var(--transition);
}

.card-header {
    border-bottom-color: var(--border);
    padding: 1rem 1.25rem;
}

/* ===== Stats Cards ===== */
.stats-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: transform var(--transition), box-shadow var(--transition);
}

.stats-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stats-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.stats-info {
    display: flex;
    flex-direction: column;
}

.stats-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
}

.stats-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ===== Dataset Cards ===== */
.dataset-card {
    transition: transform var(--transition), box-shadow var(--transition);
}

.dataset-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.card-footer {
    border-top-color: var(--border);
}

/* ===== Image Grid ===== */
.image-card {
    transition: all var(--transition);
    overflow: hidden;
}

.image-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.image-card.validated {
    border: 2px solid rgba(34, 197, 94, 0.5) !important;
}

.image-thumb {
    position: relative;
    padding-top: 75%;
    background: var(--surface-light);
    overflow: hidden;
}

.image-thumb img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.image-card:hover .image-thumb img {
    transform: scale(1.05);
}

.validated-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    color: #22c55e;
    font-size: 1.25rem;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
}

.annotation-count {
    position: absolute;
    bottom: 6px;
    left: 6px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    backdrop-filter: blur(4px);
}

/* ===== Upload Zone ===== */
.upload-zone {
    border: 2px dashed rgba(99, 102, 241, 0.4);
    border-radius: var(--radius);
    padding: 2.5rem;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    background: rgba(99, 102, 241, 0.05);
}

.upload-zone:hover,
.upload-zone.drag-over {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
    transform: scale(1.01);
}

/* ===== Tables ===== */
.table {
    --bs-table-bg: transparent;
    --bs-table-hover-bg: var(--surface-hover);
    color: var(--text-primary);
}

.table th {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom-color: var(--border);
    padding: 0.75rem 1rem;
}

.table td {
    padding: 0.75rem 1rem;
    border-bottom-color: var(--border);
    vertical-align: middle;
}

/* ===== Pagination ===== */
.page-link {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text-primary);
}

.page-link:hover {
    background: var(--surface-hover);
    color: var(--primary);
    border-color: var(--border);
}

.page-item.active .page-link {
    background: var(--primary);
    border-color: var(--primary);
}

/* ===== Progress ===== */
.progress {
    background: var(--surface-light);
    border-radius: 10px;
}

/* ===== Forms ===== */
.form-control,
.form-select {
    background: var(--surface-light);
    border-color: var(--border);
    color: var(--text-primary);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control:focus,
.form-select:focus {
    background: var(--surface-light);
    border-color: var(--primary);
    color: var(--text-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.form-control::placeholder {
    color: var(--text-muted);
}

.input-group-text {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text-muted);
}

.form-label {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text-primary);
}

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

.form-check-input:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

/* ===== Buttons ===== */
.btn-primary {
    background: var(--accent-gradient);
    border: none;
    font-weight: 500;
    transition: all var(--transition);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
    background: var(--accent-gradient);
    filter: brightness(1.1);
}

.btn-outline-primary {
    border-color: rgba(99, 102, 241, 0.5);
    color: #a5b4fc;
}

.btn-outline-primary:hover {
    background: rgba(99, 102, 241, 0.15);
    border-color: var(--primary);
    color: #c7d2fe;
}

.btn-outline-secondary {
    border-color: var(--border);
    color: var(--text-muted);
}

.btn-outline-secondary:hover {
    background: var(--surface-hover);
    border-color: var(--border);
    color: var(--text-primary);
}

.btn-outline-danger:hover {
    background: rgba(239, 68, 68, 0.15);
}

/* ===== Badges ===== */
.badge {
    font-weight: 500;
    font-size: 0.75rem;
}

/* ===== Nav Pills ===== */
.nav-pills .nav-link {
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 0.875rem;
}

.nav-pills .nav-link.active {
    background: rgba(99, 102, 241, 0.2);
    color: #a5b4fc;
}

.nav-pills .nav-link:hover:not(.active) {
    color: var(--text-primary);
    background: var(--surface-hover);
}

/* ===== Alerts ===== */
.alert {
    border-radius: var(--radius-sm);
    border: none;
    font-size: 0.9rem;
}

.animate-slide-in {
    animation: slideIn 0.3s ease-out;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== List Group ===== */
.list-group-item {
    background: transparent;
    border-color: var(--border);
    color: var(--text-primary);
}

/* ===== Annotation Editor ===== */
.editor-container {
    display: flex;
    height: calc(100vh - var(--topbar-height));
    overflow: hidden;
}

.editor-toolbar {
    width: 56px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.5rem;
    gap: 0.25rem;
    flex-shrink: 0;
}

.tool-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 0.5rem 0;
}

.tool-section:not(:last-child) {
    border-bottom: 1px solid var(--border);
}

.tool-label {
    font-size: 0.6rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 2px;
}

.tool-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all var(--transition);
}

.tool-btn:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.tool-btn.active {
    background: rgba(99, 102, 241, 0.2);
    color: #a5b4fc;
}

.editor-canvas-wrapper {
    flex: 1;
    position: relative;
    background: #0a0b14;
    overflow: hidden;
}

.canvas-info {
    position: absolute;
    bottom: 8px;
    left: 8px;
    display: flex;
    gap: 1rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    background: rgba(0, 0, 0, 0.7);
    padding: 4px 10px;
    border-radius: 4px;
    backdrop-filter: blur(8px);
    z-index: 10;
}

.editor-sidebar {
    width: 260px;
    background: var(--surface);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

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

.class-selector {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
}

.annotation-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.annotation-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    margin-bottom: 2px;
}

.annotation-item:hover {
    background: var(--surface-hover);
}

.annotation-item.selected {
    background: rgba(99, 102, 241, 0.15);
    outline: 1px solid rgba(99, 102, 241, 0.4);
}

.annotation-item-color {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    flex-shrink: 0;
}

.annotation-item-info {
    flex: 1;
    min-width: 0;
}

.annotation-item-class {
    font-size: 0.8rem;
    font-weight: 500;
    display: block;
}

.annotation-item-points {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.annotation-item-delete {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px;
    border-radius: 4px;
    font-size: 0.9rem;
    opacity: 0;
    transition: all var(--transition);
}

.annotation-item:hover .annotation-item-delete {
    opacity: 1;
}

.annotation-item-delete:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.15);
}

.editor-help {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border);
}

.editor-help details summary {
    cursor: pointer;
    color: var(--text-muted);
}

.editor-help ul {
    padding-left: 1rem;
}

.editor-help li {
    margin-bottom: 2px;
    color: var(--text-muted);
}

.editor-help kbd {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    font-family: monospace;
}

/* ===== Brush Controls ===== */
.brush-controls {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
}

.brush-controls .form-range {
    flex: 1;
    height: 4px;
    accent-color: #6366f1;
}

.brush-controls .form-range::-webkit-slider-thumb {
    width: 14px;
    height: 14px;
}

/* ===== Toast Notifications ===== */
.toast-notification {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    z-index: 9999;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s ease;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.toast-notification.show {
    transform: translateY(0);
    opacity: 1;
}

.toast-success {
    background: #166534;
    color: #bbf7d0;
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.toast-danger {
    background: #991b1b;
    color: #fecaca;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.toast-warning {
    background: #92400e;
    color: #fde68a;
    border: 1px solid rgba(234, 179, 8, 0.3);
}

.toast-info {
    background: #1e3a5f;
    color: #bfdbfe;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

/* ===== Responsive ===== */
@media (max-width: 767.98px) {
    .content-wrapper {
        padding: 1rem;
    }

    .auth-card {
        padding: 1.5rem;
    }

    .editor-sidebar {
        display: none;
    }

    .editor-toolbar {
        width: 48px;
    }

    .tool-btn {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }

    .stats-card {
        padding: 1rem;
    }

    .stats-value {
        font-size: 1.25rem;
    }
}

@media (max-width: 575.98px) {
    .topbar-title h1 {
        font-size: 0.9rem;
    }

    .topbar {
        padding: 0 0.75rem !important;
        gap: 0.5rem;
    }
}

/* ===== Animations ===== */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.card,
.stats-card {
    animation: scaleIn 0.3s ease-out;
}

/* ===== Form Switch (Dark Mode) ===== */
.form-switch .form-check-input {
    background-color: var(--surface-light);
    border-color: var(--border);
}

.form-switch .form-check-input:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

/* ===== Dropdown ===== */
.dropdown-menu {
    background: var(--surface);
    border-color: var(--border);
    box-shadow: var(--shadow-md);
}

.dropdown-item {
    color: var(--text-primary);
}

.dropdown-item:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

/* ===== Modal ===== */
.modal-content {
    background: var(--surface);
    border-color: var(--border);
}

.modal-header {
    border-bottom-color: var(--border);
}

.modal-footer {
    border-top-color: var(--border);
}