/* ══════════════════════════════════════════════════════════
   FTP Connect — Design System
   Dark theme, glassmorphism, modern UI
   ══════════════════════════════════════════════════════════ */

/* ── CSS Variables ── */
:root {
    --bg-primary: #060a14;
    --bg-secondary: #0d1321;
    --bg-panel: rgba(15, 20, 40, 0.75);
    --bg-panel-solid: #0f1428;
    --bg-hover: rgba(99, 102, 241, 0.08);
    --bg-selected: rgba(99, 102, 241, 0.15);
    --bg-input: rgba(10, 14, 26, 0.6);

    --clr-primary: #6366f1;
    --clr-primary-light: #818cf8;
    --clr-accent: #8b5cf6;
    --clr-cyan: #22d3ee;
    --clr-success: #10b981;
    --clr-warning: #f59e0b;
    --clr-danger: #ef4444;

    --clr-text: #e2e8f0;
    --clr-text-secondary: #94a3b8;
    --clr-text-dim: #475569;
    --clr-border: rgba(99, 102, 241, 0.15);
    --clr-border-hover: rgba(99, 102, 241, 0.35);

    --glass-blur: 16px;
    --glass-border: 1px solid rgba(255, 255, 255, 0.06);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;

    --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 20px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 40px rgba(0,0,0,0.5);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.15);

    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Consolas', monospace;

    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html, body {
    height: 100%;
    font-family: var(--font-main);
    font-size: 14px;
    color: var(--clr-text);
    background: var(--bg-primary);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

body {
    display: flex;
    flex-direction: column;
    background:
        radial-gradient(ellipse at 20% 0%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 100%, rgba(139, 92, 246, 0.06) 0%, transparent 50%),
        var(--bg-primary);
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--clr-text-dim); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--clr-text-secondary); }

/* ── Glass Panel ── */
.panel-glass {
    background: var(--bg-panel);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

/* ══════════════════ HEADER ══════════════════ */
#app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    background: rgba(13, 19, 33, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--clr-border);
    z-index: 100;
    flex-shrink: 0;
}

.header-left, .header-right { display: flex; align-items: center; gap: 12px; }

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo h1 {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--clr-text);
}

.logo .accent {
    background: linear-gradient(135deg, var(--clr-primary), var(--clr-cyan));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Status Badge */
.status-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid;
    transition: var(--transition);
}

.status-badge.disconnected {
    border-color: rgba(239, 68, 68, 0.3);
    color: var(--clr-danger);
    background: rgba(239, 68, 68, 0.08);
}

.status-badge.connected {
    border-color: rgba(16, 185, 129, 0.3);
    color: var(--clr-success);
    background: rgba(16, 185, 129, 0.08);
}

.status-badge.connecting {
    border-color: rgba(245, 158, 11, 0.3);
    color: var(--clr-warning);
    background: rgba(245, 158, 11, 0.08);
}

.status-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: currentColor;
}

.status-badge.connected .status-dot {
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 currentColor; }
    50% { opacity: 0.7; box-shadow: 0 0 0 4px transparent; }
}

/* ══════════════════ BUTTONS ══════════════════ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-main);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    outline: none;
}

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

.btn-glass {
    background: rgba(255, 255, 255, 0.05);
    color: var(--clr-text-secondary);
    border: 1px solid rgba(255, 255, 255, 0.08);
}
.btn-glass:hover { background: rgba(255, 255, 255, 0.1); color: var(--clr-text); border-color: var(--clr-border-hover); }

.btn-primary {
    background: linear-gradient(135deg, var(--clr-primary), var(--clr-accent));
    color: #fff;
    box-shadow: 0 2px 12px rgba(99, 102, 241, 0.3);
}
.btn-primary:hover { box-shadow: 0 4px 20px rgba(99, 102, 241, 0.45); transform: translateY(-1px); }

.btn-accent {
    background: rgba(139, 92, 246, 0.15);
    color: var(--clr-accent);
    border: 1px solid rgba(139, 92, 246, 0.25);
}
.btn-accent:hover { background: rgba(139, 92, 246, 0.25); border-color: rgba(139, 92, 246, 0.4); }

.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    color: var(--clr-danger);
    border: 1px solid rgba(239, 68, 68, 0.25);
}
.btn-danger:hover { background: rgba(239, 68, 68, 0.25); }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 6px; }

/* ══════════════════ FORM CONTROLS ══════════════════ */
.form-control {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-sm);
    color: var(--clr-text);
    font-family: var(--font-main);
    font-size: 13px;
    transition: var(--transition);
    outline: none;
}

.form-control:focus {
    border-color: var(--clr-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

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

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%2394a3b8'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 28px;
}

label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--clr-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

/* ══════════════════ CONNECTION PANEL ══════════════════ */
#connection-panel {
    margin: 0 16px;
    overflow: hidden;
    transition: var(--transition-slow);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    border-top: none;
}

#connection-panel.collapsed {
    max-height: 0;
    padding: 0 16px;
    margin-bottom: 0;
    border: none;
    opacity: 0;
}

#connection-panel:not(.collapsed) {
    max-height: 300px;
    padding: 16px;
    margin-bottom: 8px;
    opacity: 1;
}

.connection-grid {
    display: grid;
    grid-template-columns: 120px 1fr 80px 1fr 1fr auto;
    gap: 12px;
    align-items: end;
}

.fg-host { grid-column: span 1; }

.recent-list { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--clr-border); }
.recent-list h4 { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--clr-text-dim); margin-bottom: 8px; }

.recent-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    font-size: 12px;
    color: var(--clr-text-secondary);
}

.recent-item:hover { background: var(--bg-hover); color: var(--clr-text); }

.recent-item .recent-protocol {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
    background: rgba(99, 102, 241, 0.15);
    color: var(--clr-primary-light);
    margin-right: 8px;
}

.recent-item .recent-delete {
    opacity: 0;
    background: none;
    border: none;
    color: var(--clr-danger);
    cursor: pointer;
    padding: 2px;
    transition: var(--transition);
}
.recent-item:hover .recent-delete { opacity: 1; }

/* ══════════════════ MAIN PANELS ══════════════════ */
#panels-container {
    display: flex;
    flex: 1;
    gap: 0;
    padding: 8px 16px;
    min-height: 0;
    overflow: hidden;
}

.file-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 300px;
    overflow: hidden;
}

/* Panel Header */
.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--clr-border);
    flex-shrink: 0;
}

.panel-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 13px;
    color: var(--clr-text-secondary);
}

.panel-title svg { color: var(--clr-primary-light); }

.panel-actions { display: flex; gap: 6px; align-items: center; }

/* Breadcrumb */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 6px 14px;
    font-size: 12px;
    color: var(--clr-text-dim);
    border-bottom: 1px solid rgba(255,255,255,0.03);
    flex-shrink: 0;
    overflow-x: auto;
    white-space: nowrap;
    font-family: var(--font-mono);
}

.crumb {
    padding: 2px 6px;
    border-radius: 4px;
    cursor: pointer;
    transition: var(--transition);
    color: var(--clr-text-secondary);
}

.crumb:hover { background: var(--bg-hover); color: var(--clr-primary-light); }
.crumb.crumb-placeholder { cursor: default; color: var(--clr-text-dim); font-family: var(--font-main); }
.crumb.crumb-placeholder:hover { background: none; color: var(--clr-text-dim); }

.crumb-separator {
    color: var(--clr-text-dim);
    margin: 0 2px;
    user-select: none;
}

/* File List */
.file-list-container {
    flex: 1;
    position: relative;
    overflow-y: auto;
    overflow-x: hidden;
    user-select: none;
}

body.is-drag-selecting {
    user-select: none;
}

.selection-box {
    position: absolute;
    border: 1px solid rgba(129, 140, 248, 0.95);
    background: rgba(99, 102, 241, 0.2);
    border-radius: 4px;
    pointer-events: none;
    z-index: 15;
}

#ftp-panel.drag-over {
    border-color: rgba(34, 211, 238, 0.65);
    box-shadow: 0 0 0 2px rgba(34, 211, 238, 0.25), var(--shadow-md);
}

#ftp-panel.drag-over .file-list-container {
    background: rgba(34, 211, 238, 0.06);
}

.file-list {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.file-list thead {
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--bg-panel-solid);
}

.file-list th {
    padding: 8px 12px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--clr-text-dim);
    border-bottom: 1px solid var(--clr-border);
    cursor: pointer;
    user-select: none;
    transition: var(--transition);
}

.file-list th:hover { color: var(--clr-text-secondary); }

.th-check { width: 36px; cursor: default; }
.th-name { width: auto; }
.th-size { width: 90px; }
.th-date { width: 140px; }
.th-perms { width: 100px; }

.file-list th input[type="checkbox"],
.file-list td input[type="checkbox"] {
    width: 14px; height: 14px;
    accent-color: var(--clr-primary);
    cursor: pointer;
}

.file-list tbody tr {
    transition: var(--transition);
    cursor: pointer;
    border-bottom: 1px solid rgba(255,255,255,0.02);
}

.file-list tbody tr:hover { background: var(--bg-hover); }
.file-list tbody tr.selected { background: var(--bg-selected); }

.file-list td {
    padding: 6px 12px;
    font-size: 13px;
    color: var(--clr-text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-list td.file-name-cell {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--clr-text);
    font-weight: 400;
}

.file-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 5px;
    flex-shrink: 0;
    font-size: 12px;
}

.file-icon.folder {
    background: rgba(245, 158, 11, 0.12);
    color: var(--clr-warning);
}

.file-icon.file {
    background: rgba(99, 102, 241, 0.12);
    color: var(--clr-primary-light);
}

.file-icon.image { background: rgba(236, 72, 153, 0.12); color: #ec4899; }
.file-icon.code { background: rgba(34, 211, 238, 0.12); color: var(--clr-cyan); }
.file-icon.archive { background: rgba(16, 185, 129, 0.12); color: var(--clr-success); }

.file-name { overflow: hidden; text-overflow: ellipsis; }

.file-list td.file-size,
.file-list td.file-date,
.file-list td.file-perms {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--clr-text-dim);
}

.empty-row td { padding: 0 !important; border: none !important; }

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    color: var(--clr-text-dim);
}

.empty-state p { margin-top: 12px; font-size: 13px; line-height: 1.6; }

/* Panel Footer */
.panel-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 14px;
    border-top: 1px solid var(--clr-border);
    font-size: 11px;
    color: var(--clr-text-dim);
    flex-shrink: 0;
}

/* Panel Divider */
#panel-divider {
    width: 8px;
    cursor: col-resize;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
    z-index: 10;
}

.divider-line {
    width: 2px;
    height: 40px;
    background: var(--clr-border);
    border-radius: 2px;
    transition: var(--transition);
}

#panel-divider:hover .divider-line {
    background: var(--clr-primary);
    height: 60px;
    box-shadow: var(--shadow-glow);
}

/* ══════════════════ TRANSFER BAR ══════════════════ */
#transfer-bar {
    margin: 0 16px 8px;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border-radius: var(--radius-md);
    animation: slideUp 0.3s ease;
}

.transfer-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--clr-text-secondary);
}

.transfer-info svg { color: var(--clr-cyan); animation: spin 1.5s linear infinite; }

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

.transfer-progress {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    max-width: 400px;
}

.progress-bar {
    flex: 1;
    height: 4px;
    background: rgba(255,255,255,0.05);
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--clr-primary), var(--clr-cyan));
    border-radius: 2px;
    width: 0%;
    transition: width 0.3s ease;
}

#transfer-percent {
    font-size: 12px;
    font-weight: 600;
    color: var(--clr-cyan);
    font-family: var(--font-mono);
    min-width: 36px;
    text-align: right;
}

/* ══════════════════ CONTEXT MENU ══════════════════ */
.context-menu {
    position: fixed;
    min-width: 180px;
    background: rgba(15, 20, 40, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 4px;
    z-index: 1000;
    animation: fadeScale 0.15s ease;
}

@keyframes fadeScale {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.ctx-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--clr-text-secondary);
    cursor: pointer;
    transition: var(--transition);
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: var(--font-main);
}

.ctx-item:hover { background: var(--bg-hover); color: var(--clr-text); }
.ctx-item.danger { color: var(--clr-danger); }
.ctx-item.danger:hover { background: rgba(239, 68, 68, 0.1); }

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

/* ══════════════════ MODAL ══════════════════ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fadeIn 0.2s ease;
}

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

.modal {
    width: 420px;
    max-width: 90vw;
    animation: slideUp 0.25s ease;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

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

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

.modal-body { padding: 18px; }

.modal-body .form-control { margin-top: 8px; }

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

/* ══════════════════ TOAST ══════════════════ */
#toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 3000;
    display: flex;
    flex-direction: column-reverse;
    gap: 8px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: rgba(15, 20, 40, 0.95);
    backdrop-filter: blur(16px);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    font-size: 13px;
    color: var(--clr-text);
    min-width: 280px;
    max-width: 420px;
    animation: toastIn 0.3s ease;
}

.toast.toast-out { animation: toastOut 0.25s ease forwards; }

@keyframes toastIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(30px); } }

.toast-icon { flex-shrink: 0; }
.toast.success .toast-icon { color: var(--clr-success); }
.toast.error .toast-icon { color: var(--clr-danger); }
.toast.info .toast-icon { color: var(--clr-cyan); }
.toast.warning .toast-icon { color: var(--clr-warning); }

.toast.success { border-left: 3px solid var(--clr-success); }
.toast.error { border-left: 3px solid var(--clr-danger); }
.toast.info { border-left: 3px solid var(--clr-cyan); }
.toast.warning { border-left: 3px solid var(--clr-warning); }

/* ══════════════════ LOADING SKELETON ══════════════════ */
.skeleton-row td { position: relative; overflow: hidden; }

.skeleton {
    display: inline-block;
    height: 12px;
    border-radius: 4px;
    background: rgba(255,255,255,0.04);
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { background-position: -200px 0; }
    100% { background-position: 200px 0; }
}

/* ══════════════════ RESPONSIVE ══════════════════ */
@media (max-width: 900px) {
    .connection-grid {
        grid-template-columns: 1fr 1fr;
    }

    .fg-host { grid-column: span 2; }

    #panels-container {
        flex-direction: column;
    }

    #panel-divider {
        width: 100%;
        height: 8px;
        cursor: row-resize;
    }

    .divider-line {
        width: 40px;
        height: 2px;
    }

    .file-panel { min-width: 0; }
}

@media (max-width: 600px) {
    .connection-grid { grid-template-columns: 1fr; }
    .fg-host { grid-column: span 1; }
    .panel-header { flex-direction: column; gap: 8px; align-items: flex-start; }
    .panel-actions { width: 100%; justify-content: flex-start; flex-wrap: wrap; }
    .btn span.hide-mobile { display: none; }
}
