/* ============================================
   Haru GDrive Downloader - Premium Dark UI
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --bg-primary: #0f1117;
    --bg-secondary: #1a1d27;
    --bg-card: rgba(26, 29, 39, 0.85);
    --bg-card-hover: rgba(35, 39, 52, 0.9);
    --bg-glass: rgba(255, 255, 255, 0.04);
    --bg-input: rgba(255, 255, 255, 0.06);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-active: rgba(99, 102, 241, 0.5);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --accent-glow: rgba(99, 102, 241, 0.25);
    --success: #22c55e;
    --success-bg: rgba(34, 197, 94, 0.12);
    --error: #ef4444;
    --error-bg: rgba(239, 68, 68, 0.12);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.12);
    --gradient-accent: linear-gradient(135deg, #6366f1, #8b5cf6);
    --gradient-bg: linear-gradient(180deg, #0f1117 0%, #151822 100%);
    --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.15);
    --radius: 16px;
    --radius-sm: 10px;
    --radius-xs: 6px;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--gradient-bg);
    color: var(--text-primary);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ============= Layout ============= */

.app-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 32px 20px;
}

/* ============= Header ============= */

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
}

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

.app-logo-icon {
    width: 44px;
    height: 44px;
    background: var(--gradient-accent);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: white;
    box-shadow: var(--shadow-glow);
}

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

.app-logo h1 span {
    color: var(--accent);
}

.btn-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-glass);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    font-size: 16px;
}

.btn-icon:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    border-color: var(--border-active);
}

/* ============= Cards ============= */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
    backdrop-filter: blur(12px);
    box-shadow: var(--shadow-card);
    transition: var(--transition);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-title i {
    color: var(--accent);
    font-size: 14px;
}

/* ============= Settings Panel ============= */

.settings-panel {
    display: none;
    animation: slideDown 0.3s ease;
}

.settings-panel.visible {
    display: block;
}

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

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

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

.form-input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    transition: var(--transition);
    outline: none;
}

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

.form-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ============= Buttons ============= */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    white-space: nowrap;
}

.btn-primary {
    background: var(--gradient-accent);
    color: white;
    box-shadow: 0 2px 12px var(--accent-glow);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px var(--accent-glow);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-success {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: white;
    box-shadow: 0 2px 12px rgba(34, 197, 94, 0.25);
}

.btn-success:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(34, 197, 94, 0.3);
}

.btn-sm {
    padding: 8px 14px;
    font-size: 12px;
    border-radius: var(--radius-xs);
}

.btn-ghost {
    background: var(--bg-glass);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

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

/* ============= Link Input Area ============= */

.link-input-group {
    display: flex;
    gap: 10px;
}

.link-input-group .form-input {
    flex: 1;
    font-size: 15px;
    padding: 14px 18px;
}

/* ============= Breadcrumb ============= */

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 14px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
}

.breadcrumb-link {
    color: var(--accent);
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
    padding: 2px 4px;
    border-radius: 4px;
}

.breadcrumb-link:hover {
    color: var(--accent-hover);
    background: var(--accent-glow);
}

.breadcrumb-sep {
    color: var(--text-muted);
    font-size: 10px;
}

.breadcrumb-current {
    color: var(--text-primary);
    font-weight: 600;
}

/* ============= File List ============= */

.scan-result {
    display: none;
    animation: slideDown 0.3s ease;
}

.scan-result.visible {
    display: block;
}

.folder-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.folder-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.folder-title i {
    color: #facc15;
}

.folder-meta {
    display: flex;
    gap: 16px;
    margin-top: 8px;
    margin-bottom: 16px;
}

.meta-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.meta-badge i {
    font-size: 11px;
}

.file-list {
    list-style: none;
    max-height: 460px;
    overflow-y: auto;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.file-list::-webkit-scrollbar {
    width: 6px;
}

.file-list::-webkit-scrollbar-track {
    background: transparent;
}

.file-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    transition: var(--transition);
    gap: 12px;
}

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

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

.file-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

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

.file-icon.image {
    background: rgba(236, 72, 153, 0.12);
    color: #ec4899;
}

.file-icon.video {
    background: rgba(168, 85, 247, 0.12);
    color: #a855f7;
}

.file-icon.folder {
    background: rgba(250, 204, 21, 0.12);
    color: #facc15;
}

.file-icon.generic {
    background: rgba(99, 102, 241, 0.12);
    color: #6366f1;
}

.file-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-size {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
    min-width: 70px;
    text-align: right;
}

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

.btn-download-single {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-glass);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    font-size: 12px;
}

.btn-download-single:hover {
    background: var(--accent-glow);
    color: var(--accent);
    border-color: var(--accent);
}

/* ============= Task List ============= */

.task-list {
    list-style: none;
}

.task-empty {
    text-align: center;
    padding: 32px;
    color: var(--text-muted);
    font-size: 13px;
    font-style: italic;
}

.task-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    transition: var(--transition);
}

.task-item:hover {
    border-color: rgba(255, 255, 255, 0.12);
}

.task-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.task-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.task-path {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.task-path i {
    font-size: 10px;
    margin-right: 2px;
}

.task-progress-bar {
    width: 120px;
    height: 6px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
    overflow: hidden;
    flex-shrink: 0;
}

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

.task-progress-fill.completed {
    background: linear-gradient(135deg, #22c55e, #16a34a);
}

.task-progress-fill.error {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

.task-status {
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.task-status.downloading {
    color: var(--accent);
}

.task-status.completed {
    color: var(--success);
}

.task-status.error {
    color: var(--error);
}

/* ============= Toast Notification ============= */

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    animation: toastIn 0.35s ease;
    backdrop-filter: blur(12px);
    max-width: 380px;
}

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

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

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

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

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

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

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

/* ============= Spinner ============= */

.spinner {
    animation: spin 1s linear infinite;
}

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

/* ============= Responsive ============= */

@media (max-width: 640px) {
    .app-container {
        padding: 16px 12px;
    }

    .app-header {
        margin-bottom: 20px;
        padding-bottom: 16px;
    }

    .app-logo h1 {
        font-size: 18px;
    }

    .card {
        padding: 16px;
        border-radius: 12px;
    }

    .link-input-group {
        flex-direction: column;
    }

    .folder-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .file-item {
        padding: 10px 12px;
    }

    .file-name {
        max-width: 160px;
    }

    .task-progress-bar {
        width: 80px;
    }
}
