/* ==========================================================================
   CarePDF - Upload Zone & File Cards (Redesigned)
   Simple, User-Friendly, Reliable, Smooth
   ========================================================================== */

/* ==========================================================================
   1. Upload Zone Container
   ========================================================================== */

.upload-section {
    margin-bottom: 24px;
}

.upload-zone {
    position: relative;
    background: #ffffff;
    border: 2px dashed #d1d5db;
    border-radius: 16px;
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 280px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.upload-zone:hover {
    border-color: #9ca3af;
    background: #f9fafb;
}

/* Drag over state */
.upload-zone.dragover {
    border-color: var(--primary);
    border-style: solid;
    background: #fef2f2;
    transform: scale(1.01);
}

.upload-zone.dragover .upload-icon {
    transform: scale(1.1);
    background: var(--primary);
}

.upload-zone.dragover .upload-icon svg {
    color: #ffffff;
}

/* Has files state */
.upload-zone.has-files {
    padding: 16px;
    min-height: auto;
    cursor: default;
    border-style: solid;
    border-color: #e5e7eb;
}

.upload-zone.has-files:hover {
    background: #ffffff;
}

/* ==========================================================================
   2. Upload Zone Content (Empty State)
   ========================================================================== */

.upload-zone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.upload-zone.has-files .upload-zone-content {
    display: none;
}

/* Upload Icon */
.upload-icon {
    width: 72px;
    height: 72px;
    background: #fef2f2;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.upload-icon svg {
    width: 32px;
    height: 32px;
    color: var(--primary);
    transition: color 0.2s ease;
}

/* Upload Text */
.upload-zone h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: #111827;
    margin: 0;
}

.upload-zone p {
    font-size: 0.875rem;
    color: #6b7280;
    margin: 0;
}

/* Upload Button */
.upload-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: var(--primary);
    color: #ffffff;
    font-size: 0.9375rem;
    font-weight: 600;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 8px;
}

.upload-btn:hover {
    background: var(--primary-600);
    transform: translateY(-1px);
}

.upload-btn svg {
    width: 18px;
    height: 18px;
}

/* File formats */
.upload-formats {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 12px;
}

.upload-format {
    padding: 4px 12px;
    font-size: 0.6875rem;
    font-weight: 600;
    color: #6b7280;
    background: #f3f4f6;
    border-radius: 100px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ==========================================================================
   3. File List Grid
   ========================================================================== */

.file-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 16px;
    padding: 8px;
    width: 100%;
}

.file-list.hidden {
    display: none;
}

/* ==========================================================================
   4. File Card
   ========================================================================== */

.file-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 12px;
    cursor: grab;
    transition: all 0.15s ease;
    user-select: none;
}

.file-card:hover {
    border-color: #d1d5db;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

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

/* File card entering animation */
.file-card.entering {
    animation: fileEnter 0.3s ease forwards;
}

@keyframes fileEnter {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* File card removing animation */
.file-card.removing {
    animation: fileExit 0.2s ease forwards;
}

@keyframes fileExit {
    to {
        opacity: 0;
        transform: scale(0.9);
    }
}

/* ==========================================================================
   5. File Thumbnail
   ========================================================================== */

.file-thumbnail {
    width: 100%;
    aspect-ratio: 3/4;
    background: #f9fafb;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
}

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

/* File type icon fallback */
.file-type-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px;
}

.file-type-icon svg {
    width: 32px;
    height: 32px;
    color: #9ca3af;
}

.file-ext {
    font-size: 0.625rem;
    font-weight: 700;
    color: #ffffff;
    background: var(--primary);
    padding: 2px 8px;
    border-radius: 4px;
    text-transform: uppercase;
}

/* Thumbnail loading */
.thumbnail-loader {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 8px;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.file-thumbnail.loaded .thumbnail-loader {
    opacity: 0;
    pointer-events: none;
}

.loader-spinner {
    width: 24px;
    height: 24px;
    border: 2px solid #e5e7eb;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* ==========================================================================
   6. File Number Badge
   ========================================================================== */

.file-number {
    position: absolute;
    top: 6px;
    left: 6px;
    width: 20px;
    height: 20px;
    background: #111827;
    color: #ffffff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6875rem;
    font-weight: 700;
    z-index: 5;
}

/* ==========================================================================
   7. File Remove Button
   ========================================================================== */

.file-actions {
    position: absolute;
    top: 6px;
    right: 6px;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.file-card:hover .file-actions {
    opacity: 1;
}

.file-remove-btn {
    width: 24px;
    height: 24px;
    background: #ffffff;
    color: #ef4444;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    transition: all 0.15s ease;
}

.file-remove-btn:hover {
    background: #ef4444;
    color: #ffffff;
    transform: scale(1.1);
}

.file-remove-btn svg {
    width: 12px;
    height: 12px;
}

/* ==========================================================================
   8. File Details
   ========================================================================== */

.file-details {
    width: 100%;
    text-align: center;
}

.file-name {
    font-size: 0.75rem;
    font-weight: 500;
    color: #374151;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.page-count {
    font-size: 0.6875rem;
    color: #9ca3af;
    margin-top: 2px;
}

/* ==========================================================================
   9. Add More Card
   ========================================================================== */

.add-more-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    border: 2px dashed #d1d5db;
    border-radius: 12px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.15s ease;
    min-height: 140px;
}

.add-more-card:hover {
    border-color: var(--primary);
    background: #fef2f2;
}

.add-icon {
    width: 40px;
    height: 40px;
    background: #f3f4f6;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
    transition: all 0.15s ease;
    margin-bottom: 8px;
}

.add-more-card:hover .add-icon {
    background: var(--primary);
    color: #ffffff;
}

.add-icon svg {
    width: 20px;
    height: 20px;
}

.add-text {
    font-size: 0.75rem;
    font-weight: 500;
    color: #6b7280;
}

.add-more-card:hover .add-text {
    color: var(--primary);
}

/* ==========================================================================
   10. Sortable Drag States
   ========================================================================== */

.file-card.sortable-ghost {
    opacity: 0.4;
    border: 2px dashed var(--primary);
    background: #fef2f2;
}

.file-card.sortable-chosen {
    z-index: 100;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.file-card.sortable-drag {
    opacity: 0;
}

.file-card.sortable-fallback {
    opacity: 1 !important;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2) !important;
    transform: rotate(2deg) scale(1.02);
}

/* ==========================================================================
   11. Process Button Area
   ========================================================================== */

.process-action-wrapper {
    margin-top: 24px;
    text-align: center;
}

.process-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-width: 200px;
    padding: 14px 32px;
    background: linear-gradient(135deg, var(--primary) 0%, #dc2626 100%);
    color: #ffffff;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 14px rgba(239, 68, 68, 0.3);
}

.process-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
}

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

.process-btn svg {
    width: 20px;
    height: 20px;
}

.process-hint {
    font-size: 0.8125rem;
    color: #9ca3af;
    margin-top: 12px;
}

/* ==========================================================================
   12. Responsive - Tablet
   ========================================================================== */

@media (max-width: 768px) {
    .upload-zone {
        padding: 40px 20px;
        min-height: 240px;
    }
    
    .upload-icon {
        width: 64px;
        height: 64px;
    }
    
    .upload-icon svg {
        width: 28px;
        height: 28px;
    }
    
    .upload-zone h3 {
        font-size: 1.125rem;
    }
    
    .file-list {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 12px;
    }
    
    .file-card {
        padding: 10px;
    }
    
    /* Always show remove button on touch */
    .file-actions {
        opacity: 1;
    }
    
    .file-remove-btn {
        width: 28px;
        height: 28px;
    }
}

/* ==========================================================================
   13. Responsive - Mobile
   ========================================================================== */

@media (max-width: 480px) {
    .upload-zone {
        padding: 32px 16px;
        min-height: 200px;
        border-radius: 12px;
    }
    
    .upload-icon {
        width: 56px;
        height: 56px;
    }
    
    .upload-icon svg {
        width: 24px;
        height: 24px;
    }
    
    .upload-zone h3 {
        font-size: 1rem;
    }
    
    .upload-zone p {
        font-size: 0.8125rem;
    }
    
    .upload-btn {
        width: 100%;
        justify-content: center;
        padding: 14px 20px;
    }
    
    .upload-formats {
        gap: 6px;
    }
    
    .upload-format {
        padding: 3px 8px;
        font-size: 0.625rem;
    }
    
    .file-list {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
        padding: 4px;
    }
    
    .file-card {
        padding: 8px;
        border-radius: 10px;
    }
    
    .file-thumbnail {
        border-radius: 6px;
    }
    
    .file-number {
        width: 18px;
        height: 18px;
        font-size: 0.625rem;
        top: 4px;
        left: 4px;
    }
    
    .file-name {
        font-size: 0.6875rem;
    }
    
    .add-more-card {
        min-height: 100px;
    }
    
    .add-icon {
        width: 32px;
        height: 32px;
    }
    
    .add-icon svg {
        width: 16px;
        height: 16px;
    }
    
    .add-text {
        font-size: 0.6875rem;
    }
    
    .process-action-wrapper {
        position: sticky;
        bottom: 0;
        background: #ffffff;
        padding: 16px;
        margin: 0 -16px -16px;
        border-top: 1px solid #e5e7eb;
        box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.05);
    }
    
    .process-btn {
        width: 100%;
    }
    
    .process-hint {
        display: none;
    }
}

/* ==========================================================================
   14. Touch Device Optimizations
   ========================================================================== */

@media (hover: none) and (pointer: coarse) {
    .upload-zone:hover {
        border-color: #d1d5db;
        background: #ffffff;
    }
    
    .upload-zone:active {
        background: #f9fafb;
    }
    
    .file-card:hover {
        box-shadow: none;
    }
    
    .file-card:active {
        transform: scale(0.98);
    }
    
    .file-actions {
        opacity: 1;
    }
    
    .file-remove-btn {
        width: 30px;
        height: 30px;
    }
    
    .add-more-card:hover {
        border-color: #d1d5db;
        background: #ffffff;
    }
    
    .add-more-card:hover .add-icon {
        background: #f3f4f6;
        color: #9ca3af;
    }
    
    .add-more-card:active {
        background: #fef2f2;
        border-color: var(--primary);
    }
    
    .add-more-card:active .add-icon {
        background: var(--primary);
        color: #ffffff;
    }
}

/* ==========================================================================
   15. Notifications
   ========================================================================== */

.notification-container {
    position: fixed;
    top: 80px;
    right: 16px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 360px;
    width: calc(100% - 32px);
}

.notification {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    background: #ffffff;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border-left: 4px solid #6b7280;
    animation: slideIn 0.2s ease;
}

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

.notification.hiding {
    animation: slideOut 0.2s ease forwards;
}

@keyframes slideOut {
    to {
        opacity: 0;
        transform: translateX(20px);
    }
}

.notification-success { border-left-color: #10b981; }
.notification-error { border-left-color: #ef4444; }
.notification-warning { border-left-color: #f59e0b; }
.notification-info { border-left-color: #3b82f6; }

.notification-message {
    flex: 1;
    font-size: 0.875rem;
    color: #374151;
}

.notification-close {
    width: 24px;
    height: 24px;
    background: none;
    border: none;
    font-size: 1.25rem;
    color: #9ca3af;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.notification-close:hover {
    background: #f3f4f6;
    color: #6b7280;
}

@media (max-width: 480px) {
    .notification-container {
        top: 70px;
        right: 8px;
        left: 8px;
        max-width: none;
        width: auto;
    }
    
    .notification {
        padding: 10px 12px;
    }
    
    .notification-message {
        font-size: 0.8125rem;
    }
}

/* ==========================================================================
   16. Reduced Motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    .upload-zone,
    .file-card,
    .upload-icon,
    .add-more-card,
    .notification {
        transition: none;
        animation: none;
    }
    
    .file-card.entering,
    .file-card.removing,
    .notification.hiding {
        animation: none;
    }
}

/* ==========================================================================
   17. Dark Mode
   ========================================================================== */

[data-theme="dark"] .upload-zone {
    background: #1a1a24;
    border-color: #3d3d4a;
}

[data-theme="dark"] .upload-zone:hover {
    border-color: var(--primary);
    background: #1f1f2a;
}

[data-theme="dark"] .upload-zone.dragover {
    background: rgba(231, 76, 60, 0.1);
    border-color: var(--primary);
}

[data-theme="dark"] .upload-icon {
    background: rgba(231, 76, 60, 0.2);
}

[data-theme="dark"] .upload-text h3 {
    color: #f3f4f6;
}

[data-theme="dark"] .upload-text p {
    color: #9ca3af;
}

[data-theme="dark"] .format-badge {
    background: #2d2d3a;
    color: #9ca3af;
}

[data-theme="dark"] .file-list {
    background: transparent;
}

[data-theme="dark"] .file-card {
    background: #1a1a24;
    border-color: #3d3d4a;
}

[data-theme="dark"] .file-card:hover {
    border-color: #4d4d5a;
}

[data-theme="dark"] .file-thumbnail {
    background: #0f0f14;
}

[data-theme="dark"] .file-type-icon {
    color: #6b7280;
}

[data-theme="dark"] .file-info .file-name {
    color: #f3f4f6;
}

[data-theme="dark"] .file-info .file-size {
    color: #9ca3af;
}

[data-theme="dark"] .page-count {
    color: #9ca3af;
}

[data-theme="dark"] .file-number {
    background: #2d2d3a;
    color: #9ca3af;
}

[data-theme="dark"] .file-remove-btn {
    background: #2d2d3a;
    color: #9ca3af;
}

[data-theme="dark"] .file-remove-btn:hover {
    background: var(--error);
    color: #fff;
}

[data-theme="dark"] .add-more-card {
    background: #1a1a24;
    border-color: #3d3d4a;
}

[data-theme="dark"] .add-more-card:hover {
    border-color: var(--primary);
    background: rgba(231, 76, 60, 0.1);
}

[data-theme="dark"] .add-icon {
    background: #2d2d3a;
}

[data-theme="dark"] .add-text {
    color: #9ca3af;
}

[data-theme="dark"] .notification {
    background: #1a1a24;
    border-color: #3d3d4a;
}

[data-theme="dark"] .notification-message {
    color: #d1d5db;
}

[data-theme="dark"] .notification-close {
    color: #6b7280;
}

[data-theme="dark"] .notification-close:hover {
    color: #f3f4f6;
}
