:root {
    --bg-color: #0f172a;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    
    --accent-glow: rgba(168, 85, 247, 0.4);
    --accent-light: #d8b4fe;
    
    --glass-bg: rgba(30, 41, 59, 0.6);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    
    --drop-active-bg: rgba(168, 85, 247, 0.1);
    --drop-active-border: #a855f7;
    
    --border-radius-lg: 24px;
    --border-radius-md: 16px;
    --border-radius-sm: 8px;
    
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* Beautiful Animated Background Mesh */
.background-mesh {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    background: 
        radial-gradient(circle at 15% 50%, rgba(168, 85, 247, 0.15), transparent 40%),
        radial-gradient(circle at 85% 30%, rgba(59, 130, 246, 0.15), transparent 40%),
        radial-gradient(circle at 50% 80%, rgba(236, 72, 153, 0.1), transparent 50%);
    filter: blur(60px);
    animation: pulseBg 15s ease-in-out infinite alternate;
}

@keyframes pulseBg {
    0% { transform: scale(1); }
    100% { transform: scale(1.1) translate(2%, -2%); }
}

.app-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 3rem 1.5rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    text-align: center;
    margin-bottom: 3rem;
    animation: fadeDown 0.8s var(--transition-smooth);
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.brand-icon {
    width: 48px;
    height: 48px;
    filter: drop-shadow(0 0 15px var(--accent-glow));
}

.app-header h1 {
    font-size: 3rem;
    font-weight: 700;
    letter-spacing: -1px;
}

.app-header h1 span {
    background: linear-gradient(135deg, #a18cd1 0%, #fbc2eb 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
    font-weight: 300;
}

/* Glass Panels */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--glass-shadow);
}

/* Drop Zone */
.drop-zone {
    width: 100%;
    margin-bottom: 2rem;
    transition: var(--transition-smooth);
    animation: fadeUp 0.8s var(--transition-smooth) 0.1s both;
}

.drop-zone-content {
    border: 2px dashed rgba(255, 255, 255, 0.15);
    border-radius: var(--border-radius-lg);
    padding: 4rem 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 1rem;
    transition: var(--transition-fast);
    background: rgba(30, 41, 59, 0.3);
}

/* Drag Active State */
.drop-zone.drag-active .drop-zone-content {
    background: var(--drop-active-bg);
    border-color: var(--drop-active-border);
    transform: scale(1.02);
}

.icon-pulse {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-light);
    margin-bottom: 1rem;
    transition: var(--transition-fast);
}

.drop-zone.drag-active .icon-pulse {
    transform: scale(1.1);
    color: white;
    background: var(--accent-glow);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.8rem 1.5rem;
    border-radius: var(--border-radius-md);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: var(--transition-fast);
    outline: none;
}

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

.btn-primary {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-primary:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}

.btn-accent {
    background: linear-gradient(135deg, #a855f7 0%, #ec4899 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(168, 85, 247, 0.4);
}

.btn-accent:hover {
    box-shadow: 0 6px 20px rgba(168, 85, 247, 0.6);
    filter: brightness(1.1);
}

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

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
}

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

/* Actions Panel */
.actions-panel {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
    animation: fadeUp 0.5s var(--transition-smooth);
}

.actions-panel.hidden {
    display: none;
}

.file-stats {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.badge {
    background: rgba(168, 85, 247, 0.2);
    color: var(--accent-light);
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.85rem;
    border: 1px solid rgba(168, 85, 247, 0.3);
}

.action-buttons {
    display: flex;
    gap: 1rem;
}

/* Custom Select */
.select-wrapper {
    position: relative;
    display: inline-flex;
}
.glass-select {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 2.5rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1em;
}
.glass-select option {
    background: var(--glass-bg);
    color: var(--text-primary);
}

/* Image Grid for Reordering */
.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.image-card {
    position: relative;
    border-radius: var(--border-radius-md);
    overflow: hidden;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(10px);
    aspect-ratio: 1;
    cursor: grab;
    transition: transform 0.2s, box-shadow 0.2s;
    animation: popIn 0.4s var(--transition-smooth);
}

.image-card:active {
    cursor: grabbing;
}

.image-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
    border-color: rgba(255, 255, 255, 0.15);
}

.image-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none; /* Prevents ghost dragging of img */
}

.card-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 1rem;
    background: linear-gradient(to top, rgba(0,0,0,0.9), transparent);
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.file-name {
    font-size: 0.8rem;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 80%;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

.delete-btn {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(5px);
    transition: var(--transition-fast);
}

.delete-btn:hover {
    background: rgba(239, 68, 68, 0.8);
    color: white;
}

/* Sortable JS placeholder style */
.sortable-ghost {
    opacity: 0.4;
    transform: scale(0.95);
}

.sortable-drag {
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
    z-index: 100;
}

/* Footer */
.app-footer {
    margin-top: auto;
    text-align: center;
    padding: 2rem 0;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.footer-links {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition-fast);
}

.footer-links a:hover {
    color: white;
}

.dot {
    width: 4px;
    height: 4px;
    background: var(--text-secondary);
    border-radius: 50%;
}

/* Modals */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    width: 90%;
    max-width: 500px;
    padding: 2.5rem;
    position: relative;
    text-align: center;
}

.close-btn {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    transition: var(--transition-fast);
}

.close-btn:hover {
    color: white;
}

.modal-content h2 {
    margin-bottom: 1rem;
    color: white;
}

.modal-content p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.success-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: rgba(74, 222, 128, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
}

/* Loading Overlay for PDF gen */
.loading-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: var(--border-radius-lg);
    gap: 1rem;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255,255,255,0.1);
    border-left-color: var(--accent-light);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin { 100% { transform: rotate(360deg); } }
@keyframes fadeDown {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes popIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}
@keyframes bounceIn {
    0% { opacity: 0; transform: scale(0.8); }
    50% { transform: scale(1.05); }
    100% { opacity: 1; transform: scale(1); }
}
@keyframes easeUp {
    0% { opacity: 0; transform: translateY(30px); }
    100% { opacity: 1; transform: translateY(0); }
}

.bounce-in { animation: bounceIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; }
.ease-up { animation: easeUp 0.4s ease forwards; }

/* Responsive */
@media (max-width: 640px) {
    .app-header h1 { font-size: 2.2rem; }
    .drop-zone-content { padding: 3rem 1rem; }
    .action-buttons { width: 100%; justify-content: center; }
    .file-stats { width: 100%; justify-content: center; text-align: center; }
    .image-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}
