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

:root {
    --bg-dark: #0d1117;
    --bg-primary: #161b22;
    --bg-secondary: #21262d;
    --bg-tertiary: #30363d;
    --bg-hover: #292e36;
    --text-primary: #f0f6fc;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --accent: #58a6ff;
    --accent-hover: #79b8ff;
    --accent-bg: rgba(56, 139, 253, 0.15);
    --success: #3fb950;
    --success-bg: rgba(63, 185, 80, 0.15);
    --warning: #d29922;
    --error: #f85149;
    --border: #30363d;
    --border-light: #21262d;
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --shadow: 0 8px 24px rgba(0,0,0,0.3);
    --sidebar-width: 260px;
    --transition: 0.2s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans', Helvetica, Arial, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    overflow: hidden;
}

/* App Layout */
.app {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-primary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 1.25rem;
    border-bottom: 1px solid var(--border);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 1rem;
}

.logo svg {
    color: var(--accent);
}

.sidebar-nav {
    flex: 1;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.9375rem;
    cursor: pointer;
    transition: all var(--transition);
    width: 100%;
    text-align: left;
}

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

.nav-item.active {
    background: var(--accent-bg);
    color: var(--accent);
}

.nav-item svg {
    flex-shrink: 0;
}

.nav-item .badge {
    margin-left: auto;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.125rem 0.5rem;
    border-radius: 10px;
    min-width: 1.5rem;
    text-align: center;
}

.nav-item.active .badge {
    background: var(--accent);
    color: var(--bg-dark);
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
}

.project-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.project-info .label {
    color: var(--text-muted);
    font-size: 0.8125rem;
}

.project-info .value {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.9375rem;
}

/* Main Content */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    background: var(--bg-dark);
}

.section {
    display: none;
    animation: fadeIn 0.3s ease;
}

.section.active {
    display: block;
}

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

.section-header {
    margin-bottom: 2rem;
}

.section-header h1 {
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.section-header p {
    color: var(--text-secondary);
}

/* Upload Zone */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 3rem;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    background: var(--bg-primary);
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--accent);
    background: var(--accent-bg);
}

.upload-zone-content {
    pointer-events: none;
}

.upload-icon {
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.upload-zone h3 {
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
}

.upload-zone p {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.upload-formats {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

/* Photo Grid */
.photo-grid-header {
    display: none;
    justify-content: space-between;
    align-items: center;
    margin: 2rem 0 1rem;
}

.photo-grid-header.visible {
    display: flex;
}

.photo-grid-header h3 {
    font-size: 1rem;
    font-weight: 500;
}

.photo-grid-header h3 span {
    color: var(--text-secondary);
    font-weight: 400;
}

.photo-actions {
    display: flex;
    gap: 0.5rem;
}

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

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

.btn-icon:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 1rem;
}

.photo-item {
    position: relative;
    aspect-ratio: 4/3;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--bg-secondary);
    cursor: grab;
    transition: transform var(--transition), box-shadow var(--transition);
}

.photo-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.photo-item.sortable-ghost {
    opacity: 0.4;
}

.photo-item.sortable-chosen {
    cursor: grabbing;
}

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

.photo-item .photo-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.7) 0%, transparent 50%);
    opacity: 0;
    transition: opacity var(--transition);
    display: flex;
    align-items: flex-end;
    padding: 0.5rem;
}

.photo-item:hover .photo-overlay {
    opacity: 1;
}

.photo-item .photo-number {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    background: var(--accent);
    color: var(--bg-dark);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
}

.photo-item .photo-checkbox {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 20px;
    height: 20px;
    background: rgba(0,0,0,0.5);
    border: 2px solid rgba(255,255,255,0.5);
    border-radius: 4px;
    cursor: pointer;
    opacity: 0;
    transition: opacity var(--transition);
}

.photo-item:hover .photo-checkbox,
.photo-item .photo-checkbox:checked {
    opacity: 1;
}

.photo-item .photo-checkbox:checked {
    background: var(--accent);
    border-color: var(--accent);
}

.photo-item .photo-name {
    color: white;
    font-size: 0.75rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

.drag-hint {
    display: none;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-top: 1rem;
}

.drag-hint.visible {
    display: block;
}

/* Title Editor */
.title-editor {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

@media (max-width: 900px) {
    .title-editor {
        grid-template-columns: 1fr;
    }
}

.title-preview-container {
    position: relative;
}

.title-preview {
    aspect-ratio: 16/9;
    background: linear-gradient(135deg, #0f1419 0%, #1a1f26 100%);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    gap: 0.5rem;
    border: 1px solid var(--border);
}

.preview-badge {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: var(--bg-tertiary);
    color: var(--text-muted);
    font-size: 0.6875rem;
    font-weight: 500;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.preview-logo {
    width: 120px;
    height: 60px;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-logo img {
    max-width: 100%;
    max-height: 100%;
    filter: brightness(0) invert(1);
}

.preview-logo:not(.has-logo) {
    display: none;
}

.preview-label {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.preview-title {
    color: var(--text-primary);
    font-size: 1.5rem;
    font-weight: 700;
    text-align: center;
}

.preview-subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
}

.title-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.form-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group input[type="text"],
.form-group input[type="number"] {
    padding: 0.625rem 0.875rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9375rem;
    transition: border-color var(--transition);
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent);
}

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

.form-divider {
    height: 1px;
    background: var(--border);
    margin: 0.5rem 0;
}

.logo-section h3 {
    font-size: 0.9375rem;
    font-weight: 500;
    margin-bottom: 0.75rem;
}

.logo-upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
}

.logo-upload-area:hover {
    border-color: var(--accent);
}

.logo-upload-area.has-logo {
    padding: 1rem;
    border-style: solid;
}

.logo-upload-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
}

.logo-upload-content img {
    max-width: 150px;
    max-height: 80px;
}

.btn-text {
    background: none;
    border: none;
    color: var(--error);
    font-size: 0.8125rem;
    cursor: pointer;
    padding: 0.25rem 0;
    margin-top: 0.5rem;
}

.btn-text:hover {
    text-decoration: underline;
}

.checkbox-row {
    margin-top: 0.75rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.checkbox-label input {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
}

/* Settings */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.settings-card {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
}

.settings-card h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.slider-group {
    margin-bottom: 1.5rem;
}

.slider-group:last-child {
    margin-bottom: 0;
}

.slider-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.slider-header label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.slider-value {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--accent);
    background: var(--accent-bg);
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
}

input[type="range"] {
    width: 100%;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    transition: transform var(--transition);
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 0.375rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.setting-hint {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

.input-with-suffix {
    display: flex;
    align-items: stretch;
}

.input-with-suffix input {
    flex: 1;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.input-with-suffix .suffix {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-left: none;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    padding: 0 0.75rem;
    display: flex;
    align-items: center;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.output-specs {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.spec {
    display: flex;
    justify-content: space-between;
    font-size: 0.8125rem;
}

.spec-label {
    color: var(--text-muted);
}

.spec-value {
    color: var(--text-secondary);
}

/* Export */
.export-container {
    max-width: 500px;
    margin: 0 auto;
}

.export-summary {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.export-summary h3 {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
}

.summary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.summary-item {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.summary-label {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.summary-value {
    font-size: 1rem;
    font-weight: 600;
}

.export-progress {
    text-align: center;
    padding: 2rem 0;
}

.progress-ring-container {
    position: relative;
    display: inline-flex;
    margin-bottom: 1rem;
}

.progress-ring {
    transform: rotate(-90deg);
}

.progress-ring-bg {
    fill: none;
    stroke: var(--bg-tertiary);
    stroke-width: 8;
}

.progress-ring-fill {
    fill: none;
    stroke: var(--accent);
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 326.73;
    stroke-dashoffset: 326.73;
    transition: stroke-dashoffset 0.3s ease;
}

.progress-ring-fill.success {
    stroke: var(--success);
}

.progress-percent {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
}

.progress-message {
    color: var(--text-secondary);
    font-size: 0.9375rem;
}

.progress-message.processing {
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.export-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

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

.btn-large {
    padding: 1rem 1.5rem;
    font-size: 1rem;
}

.btn-primary {
    background: var(--accent);
    color: var(--bg-dark);
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
}

.btn-success {
    background: var(--success);
    color: var(--bg-dark);
}

.btn-success:hover:not(:disabled) {
    filter: brightness(1.1);
}

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

.btn-secondary:hover:not(:disabled) {
    background: var(--bg-tertiary);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 1000;
}

.toast {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.875rem 1.25rem;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    animation: slideIn 0.3s ease;
    max-width: 350px;
}

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

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

.toast-message {
    font-size: 0.875rem;
}

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

/* Nav Divider */
.nav-divider {
    height: 1px;
    background: var(--border);
    margin: 0.75rem 0;
}

/* Projects Section */
.projects-actions {
    margin-bottom: 1.5rem;
}

.projects-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.projects-empty {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
}

.projects-empty svg {
    margin-bottom: 1rem;
    opacity: 0.5;
}

.projects-empty p {
    font-size: 1.125rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.project-card {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    transition: border-color var(--transition);
}

.project-card:hover {
    border-color: var(--accent);
}

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

.project-card-name {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.project-card-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.project-card-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.status-badge {
    padding: 0.25rem 0.625rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: capitalize;
}

.status-badge.complete {
    background: var(--success-bg);
    color: var(--success);
}

.status-badge.processing {
    background: var(--accent-bg);
    color: var(--accent);
}

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

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

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

.project-card-actions {
    display: flex;
    gap: 0.5rem;
}

.project-card-progress {
    margin-top: 0.75rem;
}

.progress-bar-small {
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    overflow: hidden;
}

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

.project-card-message {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.375rem;
}

/* Export Note */
.export-note {
    text-align: center;
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-top: 1.5rem;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        padding: 1rem;
    }

    .photo-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }

    .project-card {
        flex-direction: column;
        align-items: stretch;
    }

    .project-card-actions {
        margin-top: 1rem;
        justify-content: flex-end;
    }
}
