@import 'normalize.css';

* {
    box-sizing: border-box;
}

:root {
    /* Premium Color Palette */
    --color-primary: #4f46e5;
    /* Indigo 600 */
    --color-primary-light: #818cf8;
    /* Indigo 400 */
    --color-primary-dark: #3730a3;
    /* Indigo 800 */
    --color-secondary: #ec4899;
    /* Pink 500 */
    --color-accent: #8b5cf6;
    /* Violet 500 */

    --bg-gradient: linear-gradient(135deg, #f0f9ff 0%, #cbebff 100%);
    --sidebar-bg: rgba(255, 255, 255, 0.85);
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: 1px solid rgba(255, 255, 255, 0.5);
    --backdrop-blur: blur(12px);

    /* Typography */
    --font-family-base: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-display: 'Outfit', sans-serif;

    /* Text Colors */
    --color-text-main: #1f2937;
    /* Gray 900 */
    --color-text-sub: #4b5563;
    /* Gray 600 */
    --color-text-weak: #9ca3af;
    /* Gray 400 */

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-glow: 0 0 15px rgba(79, 70, 229, 0.4);

    /* Radius */
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 20px;
}

body {
    font-family: var(--font-family-base);
    background: var(--bg-gradient);
    color: var(--color-text-main);
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    margin: 0;
    overflow-x: hidden;
}

/* Layout - Sidebar + Content */
.app-container {
    position: relative;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    backdrop-filter: var(--backdrop-blur);
    -webkit-backdrop-filter: var(--backdrop-blur);
    border-right: 1px solid rgba(255, 255, 255, 0.6);
    display: flex;
    flex-direction: column;
    padding: 24px;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    box-shadow: var(--shadow-md);
    transition: width 0.3s ease;
}

.main-content {
    position: relative;
    margin-left: 260px;
    /* Width of sidebar */
    padding: 40px;
    box-sizing: border-box;
    width: auto;
    min-height: 100vh;
}

/* Sidebar Components */
.logo {
    font-family: var(--font-display);
    font-size: 20px;
    /* Reduced from 26px to fit Chinese text */
    font-weight: 800;
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    margin-bottom: 48px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 8px;
    line-height: 1.4;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 20px;
    color: var(--color-text-sub);
    text-decoration: none;
    font-weight: 600;
    border-radius: var(--radius-md);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid transparent;
    position: relative;
    overflow: hidden;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.5);
    color: var(--color-primary);
    transform: translateX(4px);
}

.nav-item.active {
    background: linear-gradient(90deg, var(--color-primary), var(--color-primary-light));
    color: white;
    box-shadow: 0 8px 20px rgba(79, 70, 229, 0.25);
}

.nav-item.active i {
    color: white;
}

.nav-item i {
    font-size: 20px;
    width: 24px;
    text-align: center;
    transition: color 0.2s;
}

/* Header within Main Content */
.content-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    /* Align bottom */
    margin-bottom: 40px;
}

.page-title {
    font-family: var(--font-display);
    font-size: 36px;
    font-weight: 800;
    color: var(--color-text-main);
    letter-spacing: -0.5px;
    line-height: 1.2;
}

/* Custom Form Elements */
.custom-select-wrapper {
    position: relative;
    display: inline-block;
}

.form-select,
.filter-select,
.stats-filter-select {
    appearance: none;
    -webkit-appearance: none;
    background-color: #fff;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1em;
    min-height: 40px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: var(--radius-md);
    box-sizing: border-box;
    padding: 10px 2.5rem 10px 12px;
    color: var(--color-text-main);
    font: inherit;
    font-size: 14px;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
}

.form-select:hover,
.filter-select:hover,
.stats-filter-select:hover {
    border-color: rgba(79, 70, 229, 0.35);
}

.form-select:focus,
.filter-select:focus,
.stats-filter-select:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.form-select:disabled,
.filter-select:disabled,
.stats-filter-select:disabled {
    background-color: #f3f4f6;
    color: #9ca3af;
    cursor: not-allowed;
}

.searchable-select {
    position: relative;
    min-width: 0;
}

.searchable-select-input {
    width: 100%;
    min-height: 40px;
    padding: 10px 36px 10px 12px !important;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: var(--radius-md);
    box-sizing: border-box;
    color: var(--color-text-main);
    font: inherit;
    font-size: 14px;
    line-height: 20px;
    background: #fff;
    outline: none;
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
}

.searchable-select-input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.searchable-select-input::placeholder {
    color: #9ca3af;
}

.searchable-select-arrow {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: #6b7280;
    font-size: 12px;
    transition: transform 0.2s;
}

.searchable-select.open .searchable-select-arrow {
    transform: translateY(-50%) rotate(180deg);
}

.searchable-select-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    min-width: 200px;
    max-height: 240px;
    margin-top: 4px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.15);
    z-index: 10050;
    display: none;
}
.searchable-select.open {
    z-index: 10040;
}

.searchable-select.open .searchable-select-dropdown {
    display: block;
}

.searchable-select-search {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 10px 12px;
    background: #fff;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.searchable-select-search input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 6px;
    box-sizing: border-box;
    font: inherit;
    font-size: 13px;
    outline: none;
}

.searchable-select-search input:focus {
    border-color: var(--color-primary);
}

.searchable-select-option {
    padding: 10px 14px;
    color: var(--color-text-main);
    font-size: 14px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.searchable-select-option:hover {
    background: rgba(79, 70, 229, 0.08);
    color: var(--color-primary);
}

.searchable-select-option.selected {
    background: rgba(79, 70, 229, 0.12);
    color: var(--color-primary);
    font-weight: 600;
}

.searchable-select-empty {
    padding: 16px;
    text-align: center;
    color: #9ca3af;
    font-size: 13px;
}

.searchable-select.disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.searchable-select.disabled .searchable-select-input {
    background: #f3f4f6;
    cursor: not-allowed;
}

/* Premium Shadows & Glass Updates */
.card,
.filter-bar {
    border: 1px solid rgba(255, 255, 255, 0.8);
    box-shadow:
        0 4px 6px -1px rgba(0, 0, 0, 0.05),
        0 2px 4px -1px rgba(0, 0, 0, 0.03),
        0 20px 25px -5px rgba(0, 0, 0, 0.05);
    /* Softer, deeper shadow */
}

/* Animation utilities */
.hover-lift {
    transition: transform 0.2s;
}

.hover-lift:hover {
    transform: translateY(-2px);
}

/* Cards & Interactives */
.card {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(8px);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(255, 255, 255, 0.6);
    padding: 24px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    background: rgba(255, 255, 255, 0.95);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 24px;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.3s ease;
    gap: 8px;
    font-size: 14px;
}

/* Shared organization tree */
.org-tree-panel {
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(226, 232, 240, 0.95);
    border-radius: 12px;
    padding: 14px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.org-tree-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.org-tree-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    color: #111827;
}

.org-tree-current {
    margin-top: 4px;
    font-size: 12px;
    color: #6b7280;
}

.org-tree-reset {
    border: 1px solid #e5e7eb;
    background: #fff;
    color: #4f46e5;
    border-radius: 8px;
    padding: 6px 10px;
    font-weight: 600;
    cursor: pointer;
}

.org-tree-switch {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    padding: 4px;
    background: #f3f4f6;
    border-radius: 10px;
    margin-bottom: 10px;
}

.org-tree-switch button {
    border: 0;
    background: transparent;
    border-radius: 8px;
    padding: 7px 8px;
    color: #6b7280;
    font-weight: 700;
    cursor: pointer;
}

.org-tree-switch button.active {
    background: #fff;
    color: #4f46e5;
    box-shadow: var(--shadow-sm);
}

.org-tree-search {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    background: #fff;
    padding: 0 12px;
    margin-bottom: 10px;
    box-sizing: border-box;
}

.org-tree-search i {
    position: static;
    flex: 0 0 auto;
    color: var(--color-text-weak);
    font-size: 12px;
    line-height: 1;
    transform: none;
}

.org-tree-search input {
    flex: 1;
    width: 100%;
    min-width: 0;
    height: auto;
    border: 0;
    outline: 0;
    padding: 0;
    margin: 0;
    box-shadow: none;
    background: transparent;
    line-height: 20px;
    font-size: 13px;
}

.org-tree-body {
    max-height: 420px;
    overflow: auto;
    padding-right: 2px;
}

.org-tree-node {
    width: 100%;
    min-height: 34px;
    display: flex;
    align-items: center;
    gap: 7px;
    border: 0;
    background: transparent;
    border-radius: 8px;
    color: #374151;
    cursor: pointer;
    text-align: left;
}

.org-tree-node:hover,
.org-tree-node.active {
    background: #eef2ff;
    color: #4338ca;
}

.org-tree-toggle {
    width: 12px;
    font-size: 11px;
    color: #9ca3af;
}

.org-tree-icon {
    width: 14px;
    font-size: 13px;
}

.org-tree-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
    font-weight: 600;
}

.org-tree-meta {
    flex: 0 0 auto;
    max-width: 72px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11px;
    color: #64748b;
}

.org-tree-loading,
.org-tree-error {
    padding: 20px 8px;
    text-align: center;
    color: #64748b;
    font-size: 13px;
}

.org-tree-error {
    color: #dc2626;
}

.course-org-selector {
    display: grid;
    grid-template-columns: minmax(260px, 0.85fr) minmax(260px, 1fr);
    gap: 16px;
    align-items: start;
}

.course-org-summary {
    background: rgba(79, 70, 229, 0.04);
    border: 1px solid rgba(79, 70, 229, 0.12);
    border-radius: 12px;
    padding: 16px;
}

.course-org-line {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
}

.course-org-line span,
.course-org-fields span {
    font-size: 12px;
    color: #6b7280;
}

.course-org-line strong {
    color: #111827;
    line-height: 1.5;
}

.course-org-fields {
    display: grid;
    gap: 10px;
}

.course-org-fields div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    border-top: 1px solid rgba(79, 70, 229, 0.12);
    padding-top: 10px;
}

.course-org-fields strong {
    color: #374151;
    text-align: right;
}

@media (max-width: 1100px) {
    .course-org-selector {
        grid-template-columns: 1fr;
    }
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
    color: white;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(79, 70, 229, 0.4);
    filter: brightness(1.1);
}

/* Course Card Specifics */
.course-card {
    background: #fff;
    border-radius: var(--radius-lg);
    overflow: hidden;
    position: relative;
    box-shadow: var(--shadow-md);
    transition: all 0.3s ease;
    border: 1px solid rgba(0, 0, 0, 0.03);
    display: flex;
    flex-direction: column;
}

.course-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: var(--shadow-lg);
}

.course-cover {
    height: 180px;
    width: 100%;
    object-fit: cover;
    position: relative;
}

.course-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    color: white;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.course-info {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.course-title {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 700;
    margin: 0 0 8px 0;
    line-height: 1.4;
}

.course-meta {
    font-size: 13px;
    color: var(--color-text-sub);
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
}

.status-tag {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.status-passed {
    background: #dbeafe;
    color: #1e40af;
}

/* Grid */
.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 32px;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

.animate-fade-in {
    animation: fadeIn 0.5s ease-out forwards;
}

/* Toast 提示组件样式 */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.8);
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text-main);
    animation: slideIn 0.3s ease-out forwards;
    pointer-events: auto;
    max-width: 400px;
}

.toast i {
    font-size: 18px;
    flex-shrink: 0;
}

.toast.success {
    border-left: 4px solid #10b981;
}

.toast.success i {
    color: #10b981;
}

.toast.error {
    border-left: 4px solid #ef4444;
}

.toast.error i {
    color: #ef4444;
}

.toast.warning {
    border-left: 4px solid #f59e0b;
}

.toast.warning i {
    color: #f59e0b;
}

.toast.info {
    border-left: 4px solid #3b82f6;
}

.toast.info i {
    color: #3b82f6;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}
