/* ============================================================
   GitTree Drive - GitHub Dark Theme
   Main Stylesheet
   ============================================================ */

/* ---- CSS Variables ---- */
:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --bg-overlay: rgba(0, 0, 0, 0.5);
    --border: #30363d;
    --border-hover: #484f58;
    --text-primary: #c9d1d9;
    --text-secondary: #8b949e;
    --text-link: #58a6ff;
    --accent: #58a6ff;
    --accent-hover: #79c0ff;
    --success: #3fb950;
    --danger: #f85149;
    --warning: #d29922;
    --info: #58a6ff;
    --purple: #bc8cff;
    --pink: #f778ba;
    --font-mono: 'Cascadia Code', 'JetBrains Mono', 'Fira Code', monospace;
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-slow: 0.4s ease;
}

/* ---- Reset ---- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 14px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
}

a {
    color: var(--text-link);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

ul, ol {
    list-style: none;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

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

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 4px;
    border: 2px solid var(--bg-primary);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-hover);
}

::-webkit-scrollbar-corner {
    background: var(--bg-primary);
}

/* ---- Selection ---- */
::selection {
    background: rgba(88, 166, 255, 0.3);
    color: #fff;
}

/* ============================================================
   Button System
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 16px;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    line-height: 1.4;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
    user-select: none;
    white-space: nowrap;
}

.btn:hover {
    background: var(--bg-secondary);
    border-color: var(--border-hover);
}

.btn:active {
    transform: scale(0.97);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-primary {
    background: rgba(88, 166, 255, 0.15);
    border-color: rgba(88, 166, 255, 0.4);
    color: var(--accent);
}

.btn-primary:hover {
    background: rgba(88, 166, 255, 0.25);
    border-color: var(--accent);
}

.btn-danger {
    background: rgba(248, 81, 73, 0.1);
    border-color: rgba(248, 81, 73, 0.4);
    color: var(--danger);
}

.btn-danger:hover {
    background: rgba(248, 81, 73, 0.2);
    border-color: var(--danger);
}

.btn-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-sm {
    padding: 3px 10px;
    font-size: 12px;
}

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: var(--radius-sm);
}

.btn-icon.btn-sm {
    width: 26px;
    height: 26px;
}

.btn-success {
    background: rgba(63, 185, 80, 0.1);
    border-color: rgba(63, 185, 80, 0.4);
    color: var(--success);
}

.btn-success:hover {
    background: rgba(63, 185, 80, 0.2);
    border-color: var(--success);
}

/* ============================================================
   Form System
   ============================================================ */
input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="search"],
input[type="url"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 6px 12px;
    font-size: 13px;
    font-family: inherit;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.15);
}

input::placeholder,
textarea::placeholder {
    color: var(--text-secondary);
}

input:disabled,
select:disabled,
textarea:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238b949e' viewBox='0 0 16 16'%3E%3Cpath d='M4.427 7.427l3.396 3.396a.25.25 0 00.354 0l3.396-3.396A.25.25 0 0011.396 7H4.604a.25.25 0 00-.177.427z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 12px;
    padding-right: 32px;
    cursor: pointer;
}

textarea {
    resize: vertical;
    min-height: 80px;
}

.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

.form-hint {
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-secondary);
}

.form-row {
    display: flex;
    gap: 12px;
    align-items: center;
}

.form-row > * {
    flex: 1;
}

/* ============================================================
   Card
   ============================================================ */
.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 14px;
}

.card-body {
    padding: 16px;
}

.card-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
}

/* ============================================================
   Table
   ============================================================ */
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.table thead {
    border-bottom: 1px solid var(--border);
}

.table th {
    text-align: left;
    padding: 10px 16px;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    user-select: none;
}

.table td {
    padding: 10px 16px;
    border-top: 1px solid var(--border);
    vertical-align: middle;
}

.table tbody tr {
    transition: background var(--transition-fast);
}

.table tbody tr:hover {
    background: var(--bg-tertiary);
}

/* ============================================================
   Modal
   ============================================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-normal), visibility var(--transition-normal);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 560px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    transform: translateY(20px) scale(0.96);
    transition: transform var(--transition-normal);
}

.modal-overlay.active .modal-content {
    transform: translateY(0) scale(1);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.modal-close {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    font-size: 18px;
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid var(--border);
}

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

@keyframes slideUp {
    from { transform: translateY(20px) scale(0.96); }
    to { transform: translateY(0) scale(1); }
}

.modal-large .modal-content {
    max-width: 800px;
}

.modal-fullscreen .modal-content {
    max-width: 95vw;
    max-height: 95vh;
    width: 95vw;
    height: 95vh;
}

/* ============================================================
   Toast Notification
   ============================================================ */
.toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    min-width: 280px;
    max-width: 420px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    color: var(--text-primary);
    font-size: 13px;
    pointer-events: auto;
    animation: slideInRight 0.3s ease forwards;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.removing {
    opacity: 0;
    transform: translateX(100%);
}

.toast-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.toast-message {
    flex: 1;
    line-height: 1.4;
}

.toast-close {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 3px;
    font-size: 14px;
    transition: all var(--transition-fast);
}

.toast-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.toast-success {
    border-left: 3px solid var(--success);
}

.toast-success .toast-icon {
    color: var(--success);
}

.toast-error {
    border-left: 3px solid var(--danger);
}

.toast-error .toast-icon {
    color: var(--danger);
}

.toast-warning {
    border-left: 3px solid var(--warning);
}

.toast-warning .toast-icon {
    color: var(--warning);
}

.toast-info {
    border-left: 3px solid var(--info);
}

.toast-info .toast-icon {
    color: var(--info);
}

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

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

.layout-sidebar {
    width: 260px;
    min-width: 260px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: sticky;
    top: 0;
    overflow: hidden;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px;
    border-bottom: 1px solid var(--border);
}

.sidebar-logo {
    width: 28px;
    height: 28px;
    color: var(--accent);
}

.sidebar-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
}

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

.nav-section {
    margin-bottom: 8px;
}

.nav-section-title {
    padding: 6px 10px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all var(--transition-fast);
    user-select: none;
}

.nav-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav-item.active {
    background: rgba(88, 166, 255, 0.12);
    color: var(--accent);
    font-weight: 500;
}

.nav-item-icon {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.nav-item-badge {
    margin-left: auto;
    padding: 1px 7px;
    font-size: 11px;
    font-weight: 600;
    background: var(--bg-tertiary);
    border-radius: 10px;
    color: var(--text-secondary);
}

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

.storage-label {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.layout-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.main-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    min-height: 52px;
}

.main-content {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
}

/* ============================================================
   Toolbar
   ============================================================ */
.toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    flex-wrap: wrap;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

.toolbar-separator {
    width: 1px;
    height: 20px;
    background: var(--border);
    margin: 0 4px;
}

.toolbar-search {
    position: relative;
    flex: 1;
    max-width: 320px;
}

.toolbar-search input {
    padding-left: 34px;
}

.toolbar-search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    pointer-events: none;
}

/* ============================================================
   Breadcrumb
   ============================================================ */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 2px;
    font-size: 13px;
    flex-wrap: wrap;
    padding: 8px 0;
}

.breadcrumb-item {
    display: flex;
    align-items: center;
    gap: 2px;
}

.breadcrumb-item a {
    color: var(--text-secondary);
    padding: 3px 6px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    text-decoration: none;
}

.breadcrumb-item a:hover {
    color: var(--accent);
    background: var(--bg-tertiary);
    text-decoration: none;
}

.breadcrumb-item.current a {
    color: var(--text-primary);
    font-weight: 500;
    pointer-events: none;
}

.breadcrumb-sep {
    color: var(--text-secondary);
    margin: 0 2px;
    font-size: 11px;
    user-select: none;
}

/* ============================================================
   Progress Bar
   ============================================================ */
.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    transition: width 0.4s ease;
}

.progress-bar-fill.success {
    background: var(--success);
}

.progress-bar-fill.danger {
    background: var(--danger);
}

.progress-bar-fill.warning {
    background: var(--warning);
}

.progress-bar-lg {
    height: 10px;
    border-radius: 5px;
}

.progress-bar-lg .progress-bar-fill {
    border-radius: 5px;
}

/* ============================================================
   Badge
   ============================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.4;
    border-radius: 12px;
    white-space: nowrap;
}

.badge-primary {
    background: rgba(88, 166, 255, 0.15);
    color: var(--accent);
}

.badge-success {
    background: rgba(63, 185, 80, 0.15);
    color: var(--success);
}

.badge-danger {
    background: rgba(248, 81, 73, 0.15);
    color: var(--danger);
}

.badge-warning {
    background: rgba(210, 153, 34, 0.15);
    color: var(--warning);
}

.badge-purple {
    background: rgba(188, 140, 255, 0.15);
    color: var(--purple);
}

.badge-muted {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

/* ============================================================
   File Tree
   ============================================================ */
.tree-node {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    user-select: none;
    font-size: 13px;
    transition: background var(--transition-fast);
    white-space: nowrap;
}

.tree-node:hover {
    background: var(--bg-tertiary);
}

.tree-node.selected {
    background: rgba(88, 166, 255, 0.12);
    color: var(--accent);
}

.tree-toggle {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--text-secondary);
    transition: transform var(--transition-fast);
}

.tree-toggle.expanded {
    transform: rotate(90deg);
}

.tree-toggle svg {
    width: 12px;
    height: 12px;
}

.tree-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.tree-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tree-children {
    overflow: hidden;
    transition: height var(--transition-normal);
}

.tree-children.collapsed {
    height: 0 !important;
    overflow: hidden;
}

.tree-indent {
    display: inline-block;
    width: 16px;
    flex-shrink: 0;
}

/* ============================================================
   File Icons
   ============================================================ */
.icon-folder { color: #e8b339; }
.icon-php { color: #8892bf; }
.icon-javascript { color: #f1e05a; }
.icon-typescript { color: #3178c6; }
.icon-python { color: #3572a5; }
.icon-image { color: #58a6ff; }
.icon-video { color: #bc8cff; }
.icon-audio { color: #f778ba; }
.icon-pdf { color: #f85149; }
.icon-word { color: #2b5797; }
.icon-excel { color: #3fb950; }
.icon-archive { color: #d29922; }
.icon-code { color: #3fb950; }
.icon-markdown { color: #8b949e; }
.icon-git { color: #f0883e; }
.icon-file { color: #8b949e; }
.icon-text { color: #c9d1d9; }
.icon-font { color: #d2a8ff; }
.icon-json { color: #f0883e; }
.icon-yaml { color: #f778ba; }
.icon-html { color: #e34c26; }
.icon-css { color: #563d7c; }

.icon-sm { width: 14px; height: 14px; }
.icon-md { width: 18px; height: 18px; }
.icon-lg { width: 24px; height: 24px; }
.icon-xl { width: 32px; height: 32px; }

/* ============================================================
   File List
   ============================================================ */
.file-list {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.file-list-header {
    display: grid;
    grid-template-columns: 40px 1fr 100px 140px 100px 80px;
    gap: 8px;
    padding: 10px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    align-items: center;
}

.file-item {
    display: grid;
    grid-template-columns: 40px 1fr 100px 140px 100px 80px;
    gap: 8px;
    padding: 8px 16px;
    align-items: center;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background var(--transition-fast);
    font-size: 13px;
}

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

.file-item:hover {
    background: var(--bg-tertiary);
}

.file-item.selected {
    background: rgba(88, 166, 255, 0.08);
}

.file-item-name {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    overflow: hidden;
}

.file-item-name span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-item-size,
.file-item-type,
.file-item-date,
.file-item-actions {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.file-item-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.file-item:hover .file-item-actions {
    opacity: 1;
}

/* Grid View */
.file-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
    padding: 16px 0;
}

.file-grid-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 12px;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: center;
    border: 1px solid transparent;
}

.file-grid-item:hover {
    background: var(--bg-tertiary);
    border-color: var(--border);
}

.file-grid-item.selected {
    background: rgba(88, 166, 255, 0.08);
    border-color: rgba(88, 166, 255, 0.3);
}

.file-grid-icon {
    margin-bottom: 8px;
}

.file-grid-name {
    font-size: 12px;
    word-break: break-all;
    line-height: 1.4;
    max-height: 2.8em;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* ============================================================
   Dropzone
   ============================================================ */
.dropzone {
    position: relative;
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 40px 20px;
    text-align: center;
    transition: all var(--transition-normal);
    cursor: pointer;
}

.dropzone:hover {
    border-color: var(--accent);
    background: rgba(88, 166, 255, 0.04);
}

.dropzone-active {
    border-color: var(--accent);
    background: rgba(88, 166, 255, 0.08);
    border-style: solid;
}

.dropzone-active::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: var(--radius-lg);
    background: rgba(88, 166, 255, 0.05);
    pointer-events: none;
}

.dropzone-icon {
    font-size: 36px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.dropzone-text {
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.dropzone-hint {
    font-size: 12px;
    color: var(--text-secondary);
}

.dropzone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

/* ============================================================
   Context Menu
   ============================================================ */
.context-menu {
    position: fixed;
    z-index: 1500;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    padding: 6px;
    opacity: 0;
    visibility: hidden;
    transform: scale(0.95);
    transform-origin: top left;
    transition: opacity var(--transition-fast), visibility var(--transition-fast), transform var(--transition-fast);
}

.context-menu.visible {
    opacity: 1;
    visibility: visible;
    transform: scale(1);
}

.context-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 12px;
    font-size: 13px;
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition-fast);
    user-select: none;
}

.context-menu-item:hover {
    background: var(--bg-tertiary);
}

.context-menu-item.danger {
    color: var(--danger);
}

.context-menu-item.danger:hover {
    background: rgba(248, 81, 73, 0.12);
}

.context-menu-item-icon {
    width: 16px;
    text-align: center;
    flex-shrink: 0;
    color: var(--text-secondary);
}

.context-menu-item.danger .context-menu-item-icon {
    color: var(--danger);
}

.context-menu-item-shortcut {
    margin-left: auto;
    font-size: 11px;
    color: var(--text-secondary);
    font-family: var(--font-mono);
}

.context-menu-separator {
    height: 1px;
    background: var(--border);
    margin: 4px 8px;
}

/* ============================================================
   Storage Bar
   ============================================================ */
.storage-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
}

.storage-bar-fill {
    height: 100%;
    border-radius: 4px;
    background: var(--accent);
    transition: width 0.5s ease;
}

.storage-bar-fill.warning {
    background: var(--warning);
}

.storage-bar-fill.danger {
    background: var(--danger);
}

.storage-text {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 6px;
}

/* ============================================================
   Spinner / Loading
   ============================================================ */
.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner-sm {
    width: 16px;
    height: 16px;
    border-width: 2px;
}

.spinner-lg {
    width: 40px;
    height: 40px;
    border-width: 4px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(13, 17, 23, 0.7);
    z-index: 100;
    border-radius: inherit;
}

.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.loading-container .spinner-lg {
    border-top-color: var(--accent);
}

/* ============================================================
   Diff View
   ============================================================ */
.diff-container {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.6;
}

.diff-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
}

.diff-stats {
    display: flex;
    gap: 12px;
    font-size: 12px;
}

.diff-stat-add {
    color: var(--success);
}

.diff-stat-del {
    color: var(--danger);
}

.diff-body {
    overflow-x: auto;
}

.diff-table {
    width: 100%;
    border-collapse: collapse;
}

.diff-line {
    transition: background var(--transition-fast);
}

.diff-line:hover {
    filter: brightness(1.2);
}

.diff-line-num {
    padding: 0 12px;
    text-align: right;
    color: var(--text-secondary);
    user-select: none;
    white-space: nowrap;
    width: 60px;
    min-width: 60px;
    border-right: 1px solid var(--border);
}

.diff-line-content {
    padding: 0 16px;
    white-space: pre-wrap;
    word-break: break-all;
}

.diff-line-add {
    background: rgba(63, 185, 80, 0.1);
}

.diff-line-add .diff-line-num {
    background: rgba(63, 185, 80, 0.15);
    color: var(--success);
}

.diff-line-del {
    background: rgba(248, 81, 73, 0.1);
}

.diff-line-del .diff-line-num {
    background: rgba(248, 81, 73, 0.15);
    color: var(--danger);
}

.diff-line-info {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-style: italic;
}

.diff-line-info .diff-line-content {
    color: var(--accent);
}

.diff-hunk-header {
    background: rgba(88, 166, 255, 0.08);
    color: var(--accent);
    padding: 4px 16px;
    font-weight: 500;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

/* Inline diff highlights */
.diff-word-add {
    background: rgba(63, 185, 80, 0.3);
    border-radius: 2px;
    padding: 0 1px;
}

.diff-word-del {
    background: rgba(248, 81, 73, 0.3);
    border-radius: 2px;
    padding: 0 1px;
    text-decoration: line-through;
}

/* ============================================================
   Upload Panel
   ============================================================ */
.upload-panel {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 360px;
    max-height: 400px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 1100;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(20px);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
}

.upload-panel.visible {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
}

.upload-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 13px;
}

.upload-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.upload-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
}

.upload-item:hover {
    background: var(--bg-tertiary);
}

.upload-item-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

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

.upload-item-name {
    font-size: 12px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.upload-item-meta {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.upload-item-status {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.upload-progress {
    width: 100%;
    height: 3px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    margin-top: 6px;
    overflow: hidden;
}

.upload-progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.3s ease;
}

/* ============================================================
   Empty State
   ============================================================ */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.empty-state-icon {
    font-size: 48px;
    color: var(--text-secondary);
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.empty-state-desc {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 20px;
    max-width: 360px;
}

/* ============================================================
   Preview Panel
   ============================================================ */
.preview-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 420px;
    height: 100vh;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border);
    z-index: 900;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform var(--transition-normal);
}

.preview-panel.visible {
    transform: translateX(0);
}

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

.preview-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.preview-image {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    min-height: 300px;
    overflow: hidden;
}

.preview-image img {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
    transition: transform var(--transition-normal);
}

.preview-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid var(--border);
}

.preview-zoom-label {
    font-size: 12px;
    color: var(--text-secondary);
    min-width: 50px;
    text-align: center;
    font-family: var(--font-mono);
}

/* ============================================================
   Tabs
   ============================================================ */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    gap: 0;
}

.tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all var(--transition-fast);
    user-select: none;
}

.tab:hover {
    color: var(--text-primary);
    border-bottom-color: var(--border-hover);
}

.tab.active {
    color: var(--text-primary);
    border-bottom-color: var(--accent);
    font-weight: 500;
}

.tab-badge {
    padding: 0 6px;
    font-size: 11px;
    font-weight: 600;
    background: var(--bg-tertiary);
    border-radius: 10px;
    color: var(--text-secondary);
}

.tab.active .tab-badge {
    background: rgba(88, 166, 255, 0.15);
    color: var(--accent);
}

/* ============================================================
   Version History
   ============================================================ */
.version-list {
    display: flex;
    flex-direction: column;
}

.version-item {
    display: flex;
    gap: 16px;
    padding: 16px;
    border-bottom: 1px solid var(--border);
    transition: background var(--transition-fast);
}

.version-item:hover {
    background: var(--bg-tertiary);
}

.version-timeline {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 20px;
    flex-shrink: 0;
}

.version-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--bg-secondary);
    flex-shrink: 0;
}

.version-line {
    width: 2px;
    flex: 1;
    background: var(--border);
    margin-top: 4px;
}

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

.version-title {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 4px;
}

.version-meta {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.version-actions {
    display: flex;
    gap: 8px;
}

/* ============================================================
   Utility Classes
   ============================================================ */
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-accent { color: var(--accent); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-purple { color: var(--purple); }
.text-pink { color: var(--pink); }
.text-mono { font-family: var(--font-mono); }

.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-col { display: flex; flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }
.gap-4 { gap: 4px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }

.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-4 { margin-bottom: 4px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mr-4 { margin-right: 4px; }
.mr-8 { margin-right: 8px; }
.ml-4 { margin-left: 4px; }
.ml-auto { margin-left: auto; }

.p-8 { padding: 8px; }
.p-12 { padding: 12px; }
.p-16 { padding: 16px; }
.px-16 { padding-left: 16px; padding-right: 16px; }
.py-8 { padding-top: 8px; padding-bottom: 8px; }

.w-full { width: 100%; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }
.visible { visibility: visible; }
.invisible { visibility: hidden; }
.relative { position: relative; }
.absolute { position: absolute; }
.overflow-hidden { overflow: hidden; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 768px) {
    .layout-sidebar {
        display: none;
    }

    .file-list-header,
    .file-item {
        grid-template-columns: 32px 1fr 80px 60px;
    }

    .file-item-type,
    .file-item-actions {
        display: none;
    }

    .file-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 12px;
    }

    .toolbar {
        padding: 8px 16px;
    }

    .main-content {
        padding: 16px;
    }

    .preview-panel {
        width: 100%;
    }

    .upload-panel {
        width: calc(100% - 32px);
        right: 16px;
        bottom: 16px;
    }
}

/* ============================================================
   Print
   ============================================================ */
@media print {
    .layout-sidebar,
    .toolbar,
    .context-menu,
    .upload-panel,
    .preview-panel,
    .toast-container,
    .modal-overlay {
        display: none !important;
    }

    body {
        background: #fff;
        color: #000;
    }

    .file-item {
        border-color: #ddd;
    }
}
