/* ==========================================================================
   shadcn/ui Design System Theme
   Generated with reference to https://shadcnstudio.com/theme-generator
   ========================================================================== */

:root {
    --background: 0 0% 100%;             /* #ffffff */
    --foreground: 240 10% 3.9%;          /* #09090b */
    --card: 0 0% 100%;                   /* #ffffff */
    --card-foreground: 240 10% 3.9%;    /* #09090b */
    --popover: 0 0% 100%;
    --popover-foreground: 240 10% 3.9%;
    --primary: 240 5.9% 10%;             /* #18181b */
    --primary-foreground: 0 0% 98%;      /* #fafafa */
    --secondary: 240 4.8% 95.9%;         /* #f4f4f5 */
    --secondary-foreground: 240 5.9% 10%;/* #18181b */
    --muted: 240 4.8% 95.9%;             /* #f4f4f5 */
    --muted-foreground: 240 3.8% 46.1%;  /* #71717a */
    --accent: 240 4.8% 95.9%;
    --accent-foreground: 240 5.9% 10%;
    --destructive: 0 84.2% 60.2%;
    --destructive-foreground: 0 0% 98%;
    --border: 240 5.9% 90%;              /* #e4e4e7 */
    --input: 240 5.9% 90%;               /* #e4e4e7 */
    --ring: 240 5.9% 10%;
    --radius: 0.5rem;                    /* 8px */
    --shadow-card: 0 1px 3px 0 rgba(0, 0, 0, 0.05), 0 1px 2px -1px rgba(0, 0, 0, 0.05);

    /* Custom semantic accents */
    --success: 142 71% 45%;
    --success-foreground: 0 0% 100%;
}

.dark {
    --background: 240 10% 3.9%;          /* #09090b */
    --foreground: 0 0% 98%;              /* #fafafa */
    --card: 240 10% 4.5%;                /* #0c0c0f */
    --card-foreground: 0 0% 98%;         /* #fafafa */
    --popover: 240 10% 3.9%;
    --popover-foreground: 0 0% 98%;
    --primary: 0 0% 98%;                 /* #fafafa */
    --primary-foreground: 240 5.9% 10%;  /* #18181b */
    --secondary: 240 3.7% 15.9%;         /* #27272a */
    --secondary-foreground: 0 0% 98%;
    --muted: 240 3.7% 15.9%;
    --muted-foreground: 240 5% 64.9%;    /* #a1a1aa */
    --accent: 240 3.7% 15.9%;
    --accent-foreground: 0 0% 98%;
    --destructive: 0 62.8% 30.6%;
    --destructive-foreground: 0 0% 98%;
    --border: 240 3.7% 15.9%;            /* #27272a */
    --input: 240 3.7% 15.9%;             /* #27272a */
    --ring: 240 4.9% 83.9%;              /* #d4d4d8 */
    --shadow-card: 0 1px 3px 0 rgba(0, 0, 0, 0.3), 0 1px 2px -1px rgba(0, 0, 0, 0.3);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: hsl(var(--background));
    color: hsl(var(--foreground));
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 48px 20px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.app-container {
    width: 100%;
    max-width: 840px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    padding-bottom: 8px;
}

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

.logo-icon {
    width: 36px;
    height: 36px;
    background: hsl(var(--secondary));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: hsl(var(--foreground));
    transition: background-color 0.15s ease;
}

.logo-icon svg {
    color: hsl(var(--foreground));
    display: block;
}

.logo-text h1 {
    font-size: 20px;
    font-weight: 600;
    color: hsl(var(--foreground));
    letter-spacing: -0.025em;
    line-height: 1.2;
}

.logo-text .subtitle {
    font-size: 13px;
    color: hsl(var(--muted-foreground));
    font-weight: 400;
}

/* Status Badge */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid hsl(var(--border));
    background: hsl(var(--secondary) / 0.5);
    color: hsl(var(--muted-foreground));
}

.status-badge .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.badge-success {
    color: hsl(var(--foreground));
    border-color: hsl(var(--border));
    background: hsl(var(--secondary));
}
.badge-success .dot { background-color: #22c55e; }

.badge-stream {
    color: hsl(var(--foreground));
    border-color: hsl(var(--border));
    background: hsl(var(--secondary));
}
.badge-stream .dot {
    background-color: #06b6d4;
    box-shadow: 0 0 6px #06b6d4;
}

.badge-info {
    color: hsl(var(--muted-foreground));
}
.badge-info .dot { background-color: #60a5fa; }

/* Platform Bar */
.platform-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px;
    background: hsl(var(--secondary) / 0.4);
    border: 1px solid hsl(var(--border));
    border-radius: calc(var(--radius) + 2px);
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: var(--radius);
    font-size: 12px;
    font-weight: 500;
    color: hsl(var(--muted-foreground));
    background: transparent;
    border: 1px solid transparent;
    transition: all 0.15s ease;
    user-select: none;
}

.pill:hover {
    color: hsl(var(--foreground));
    background: hsl(var(--secondary));
    border-color: hsl(var(--border));
}

.pill svg {
    flex-shrink: 0;
    opacity: 0.75;
    transition: opacity 0.15s ease;
}

.pill:hover svg {
    opacity: 1;
}

/* Header Actions */
.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Theme Toggle Group (Segmented Pill Switch) */
.theme-toggle-group {
    display: inline-flex;
    align-items: center;
    background: hsl(var(--secondary));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    padding: 3px;
    gap: 2px;
    user-select: none;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.04);
}

.theme-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    height: 28px;
    border-radius: calc(var(--radius) - 2px);
    font-size: 12px;
    font-weight: 500;
    font-family: inherit;
    color: hsl(var(--muted-foreground));
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
}

.theme-btn:hover {
    color: hsl(var(--foreground));
}

.theme-btn svg {
    flex-shrink: 0;
    transition: transform 0.2s ease, stroke 0.15s ease;
}

.theme-btn:hover svg {
    transform: scale(1.1);
}

.theme-btn.active {
    background: hsl(var(--card));
    color: hsl(var(--foreground));
    font-weight: 600;
    border-color: hsl(var(--border));
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.08), 0 1px 2px 0 rgba(0, 0, 0, 0.04);
}

.theme-btn.active svg {
    stroke: hsl(var(--foreground));
}

.btn-icon-only {
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    color: hsl(var(--foreground));
    cursor: pointer;
}

/* Card - shadcn style */
.card {
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: calc(var(--radius) + 4px);
    box-shadow: var(--shadow-card);
    padding: 24px;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

/* Card Header & Input Section */
.card-header {
    margin-bottom: 18px;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: hsl(var(--foreground));
    letter-spacing: -0.015em;
    margin-bottom: 4px;
}

.card-description {
    font-size: 13px;
    color: hsl(var(--muted-foreground));
    line-height: 1.4;
}

.input-wrapper {
    position: relative;
    display: flex;
    gap: 8px;
    align-items: center;
}

.input-icon-box {
    position: absolute;
    left: 12px;
    color: hsl(var(--muted-foreground));
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

.input-wrapper input {
    flex: 1;
    height: 40px;
    background: transparent;
    border: 1px solid hsl(var(--input));
    border-radius: var(--radius);
    padding: 8px 12px 8px 38px;
    font-size: 14px;
    color: hsl(var(--foreground));
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input-wrapper input::placeholder {
    color: hsl(var(--muted-foreground));
}

.input-wrapper input:focus {
    border-color: hsl(var(--ring));
    box-shadow: 0 0 0 1px hsl(var(--ring));
}

/* shadcn Button Variants */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 40px;
    padding: 0 16px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s ease;
    text-decoration: none;
    white-space: nowrap;
    user-select: none;
}

.btn-primary {
    background-color: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}
.btn-primary:hover {
    opacity: 0.9;
}

.btn-secondary {
    background-color: hsl(var(--secondary));
    color: hsl(var(--secondary-foreground));
}
.btn-secondary:hover {
    opacity: 0.8;
}

.btn-success {
    background-color: #10b981;
    color: #ffffff;
}
.btn-success:hover {
    background-color: #059669;
}

.btn-outline {
    background: transparent;
    border-color: hsl(var(--border));
    color: hsl(var(--foreground));
}
.btn-outline:hover {
    background-color: hsl(var(--accent));
    color: hsl(var(--accent-foreground));
}

.btn-ghost {
    background: transparent;
    color: hsl(var(--muted-foreground));
    border-color: transparent;
}
.btn-ghost:hover {
    background-color: hsl(var(--accent));
    color: hsl(var(--foreground));
}

.btn-sm {
    height: 32px;
    padding: 0 12px;
    font-size: 12px;
}

.btn-block {
    width: 100%;
}

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

.btn-icon {
    display: inline-block;
    vertical-align: middle;
    flex-shrink: 0;
}

/* Error message */
.error-msg {
    margin-top: 10px;
    padding: 10px 14px;
    border-radius: var(--radius);
    background: hsl(var(--destructive) / 0.15);
    border: 1px solid hsl(var(--destructive) / 0.3);
    color: #f87171;
    font-size: 13px;
    font-weight: 500;
}

/* Results Section */
.results-card {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid hsl(var(--border));
}

.results-header {
    margin-bottom: 20px;
}

.platform-meta {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.badge-platform {
    background: hsl(var(--secondary));
    color: hsl(var(--foreground));
    border: 1px solid hsl(var(--border));
    padding: 2px 8px;
    border-radius: 9999px;
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-count {
    background: transparent;
    color: hsl(var(--muted-foreground));
    border: 1px solid hsl(var(--border));
    padding: 2px 8px;
    border-radius: 9999px;
    font-size: 11px;
    font-weight: 500;
}

.page-title {
    font-size: 17px;
    font-weight: 600;
    color: hsl(var(--foreground));
    line-height: 1.4;
    letter-spacing: -0.015em;
}

/* Single Item View */
.single-layout {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    background: hsl(var(--card));
    padding: 16px;
    border-radius: var(--radius);
    border: 1px solid hsl(var(--border));
}

.single-thumbnail-wrapper {
    position: relative;
    width: 240px;
    aspect-ratio: 16 / 9;
    border-radius: calc(var(--radius) - 2px);
    overflow: hidden;
    background: hsl(var(--secondary));
    flex-shrink: 0;
    border: 1px solid hsl(var(--border));
}

.single-thumbnail-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.type-badge {
    position: absolute;
    bottom: 6px;
    right: 6px;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.03em;
}

.single-details {
    flex: 1;
    min-width: 260px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.item-title {
    font-size: 15px;
    font-weight: 500;
    color: hsl(var(--foreground));
    margin-bottom: 16px;
    line-height: 1.4;
}

.single-controls {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.select-group {
    flex: 1;
    min-width: 180px;
}

.select-group label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: hsl(var(--muted-foreground));
    margin-bottom: 6px;
}

.form-select {
    width: 100%;
    height: 40px;
    background: hsl(var(--card));
    border: 1px solid hsl(var(--input));
    border-radius: var(--radius);
    color: hsl(var(--foreground));
    padding: 8px 12px;
    font-size: 13px;
    outline: none;
    cursor: pointer;
    transition: border-color 0.15s ease;
}

.form-select:focus {
    border-color: hsl(var(--ring));
}

/* Multi-Item View */
.multi-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid hsl(var(--border));
    font-size: 13px;
    color: hsl(var(--muted-foreground));
}

.selection-actions {
    display: flex;
    gap: 6px;
}

.items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 12px;
    max-height: 460px;
    overflow-y: auto;
    padding-right: 4px;
    margin-bottom: 20px;
}

.item-card {
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: relative;
    transition: border-color 0.15s ease, background-color 0.15s ease;
    cursor: pointer;
}

.item-card:hover {
    border-color: hsl(var(--muted-foreground));
}

.item-card.selected {
    border-color: hsl(var(--foreground));
    background: hsl(var(--secondary) / 0.5);
}

.item-card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.item-checkbox {
    width: 16px;
    height: 16px;
    accent-color: hsl(var(--primary));
    cursor: pointer;
}

.item-type-tag {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid hsl(var(--border));
    background: hsl(var(--secondary));
    color: hsl(var(--foreground));
}

.tag-photo {
    background: hsl(var(--secondary));
    color: hsl(var(--muted-foreground));
}

.item-thumb-box {
    width: 100%;
    aspect-ratio: 16 / 9;
    background: hsl(var(--secondary));
    border-radius: calc(var(--radius) - 2px);
    overflow: hidden;
    position: relative;
    border: 1px solid hsl(var(--border));
}

.item-thumb-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.item-card-title {
    font-size: 13px;
    font-weight: 500;
    color: hsl(var(--foreground));
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.item-card-quality select {
    width: 100%;
    height: 32px;
    background: hsl(var(--card));
    border: 1px solid hsl(var(--input));
    border-radius: calc(var(--radius) - 2px);
    color: hsl(var(--foreground));
    padding: 4px 8px;
    font-size: 12px;
    outline: none;
}

/* Confirm Bar */
.confirm-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    background: hsl(var(--secondary) / 0.4);
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
}

.selected-summary {
    font-size: 13px;
    font-weight: 500;
    color: hsl(var(--muted-foreground));
}

/* Progress Section - shadcn style */
.progress-section {
    margin-top: 24px;
    padding: 20px;
    background: hsl(var(--card));
    border-radius: var(--radius);
    border: 1px solid hsl(var(--border));
}

.progress-header {
    display: flex;
    justify-content: space-between;
    font-weight: 500;
    margin-bottom: 10px;
    font-size: 13px;
}

.progress-bar-bg {
    width: 100%;
    height: 8px;
    background: hsl(var(--secondary));
    border-radius: 9999px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: hsl(var(--foreground));
    border-radius: 9999px;
    transition: width 0.3s ease;
}

.progress-bar-queued {
    background: repeating-linear-gradient(
        -45deg,
        hsl(var(--muted-foreground) / 0.4),
        hsl(var(--muted-foreground) / 0.4) 10px,
        hsl(var(--foreground)) 10px,
        hsl(var(--foreground)) 20px
    ) !important;
    background-size: 200% 100%;
    animation: progress-stripe-move 1.5s linear infinite;
}

@keyframes progress-stripe-move {
    0% { background-position: 100% 0; }
    100% { background-position: 0 0; }
}

.progress-stats {
    display: flex;
    justify-content: space-between;
    margin-top: 10px;
    font-size: 12px;
    color: hsl(var(--muted-foreground));
}

/* Download Results */
.download-result {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid hsl(var(--border));
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.success-header {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #22c55e;
    font-weight: 500;
    font-size: 14px;
}

.check-icon {
    width: 18px;
    height: 18px;
}

.zip-container {
    margin: 4px 0;
}

.files-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.file-item-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: hsl(var(--secondary) / 0.3);
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    transition: background-color 0.15s ease;
}

.file-item-row:hover {
    background: hsl(var(--secondary) / 0.6);
}

.file-item-info {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-type-pill {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid hsl(var(--border));
    background: hsl(var(--secondary));
    color: hsl(var(--foreground));
    text-transform: uppercase;
}

/* Footer / Tips */
.footer-tips h3 {
    font-size: 13px;
    font-weight: 600;
    color: hsl(var(--foreground));
    margin-bottom: 6px;
    letter-spacing: -0.01em;
}

.footer-desc {
    font-size: 13px;
    color: hsl(var(--muted-foreground));
    line-height: 1.5;
}

.ttl-notice {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: hsl(var(--secondary) / 0.6);
    border: 1px dashed hsl(var(--border));
    border-radius: var(--radius);
    font-size: 12px;
    color: hsl(var(--muted-foreground));
    margin-bottom: 6px;
}

.ttl-notice svg {
    flex-shrink: 0;
    color: hsl(var(--foreground));
}

/* Spinner */
.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid hsl(var(--primary-foreground) / 0.3);
    border-top-color: hsl(var(--primary-foreground));
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.hidden {
    display: none !important;
}
