/* =========== Global Styles =========== */
:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #f1f5f9;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --border-radius: 16px;
    --border-radius-sm: 8px;
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    --gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

* {
    box-sizing: border-box;
}

html, body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    min-height: 100vh;
}

/* =========== Layout =========== */
.app-container {
    min-height: 100vh;
}

.main-content {
    width: 100%;
    max-width: none;
    padding: 0;
}

/* =========== Hero Section =========== */
.hero-section {
    background: var(--gradient);
    padding: 4rem 2rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.hero-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.1'%3E%3Ccircle cx='30' cy='30' r='2'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E") repeat;
}

.hero-content {
    position: relative;
    z-index: 1;
}

.brand-header {
    max-width: 600px;
    margin: 0 auto;
}

.brand-title {
    font-size: 3.5rem;
    font-weight: 800;
    color: white;
    margin: 0 0 1rem 0;
    text-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.brand-icon {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.brand-subtitle {
    font-size: 1.25rem;
    color: rgba(255, 255, 255, 0.9);
    margin: 0;
    font-weight: 400;
}

/* =========== Main Container =========== */
.main-container {
    max-width: 1200px;
    margin: -2rem auto 0;
    padding: 0 2rem 4rem;
    position: relative;
    z-index: 2;
}

/* =========== Conversion Card =========== */
.conversion-card {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    padding: 2.5rem;
    margin-bottom: 3rem;
    border: 1px solid var(--border-color);
}

/* =========== Upload Section =========== */
.upload-section {
    margin-bottom: 2rem;
}

.upload-area {
    border: 3px dashed var(--border-color);
    border-radius: var(--border-radius);
    padding: 3rem 2rem;
    text-align: center;
    background: var(--secondary-color);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.upload-area:hover {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.05);
    transform: translateY(-2px);
}

.upload-area.drag-active {
    border-color: var(--success-color);
    background: rgba(16, 185, 129, 0.1);
    transform: scale(1.02);
    box-shadow: var(--shadow);
}

.upload-content {
    color: var(--text-secondary);
}

.upload-icon {
    font-size: 4rem;
    color: var(--primary-color);
    margin-bottom: 1.5rem;
}

.upload-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 0.5rem 0;
}

.upload-subtitle {
    font-size: 1rem;
    margin: 0 0 1.5rem 0;
}

.supported-formats {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.format-badge {
    background: var(--primary-color);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 500;
}

.file-input {
    display: none !important;
}

.btn-select-files {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.875rem 2rem;
    border-radius: var(--border-radius-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 1.5rem auto 0;
    box-shadow: 0 4px 14px 0 rgba(99, 102, 241, 0.39);
}

.btn-select-files:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px 0 rgba(99, 102, 241, 0.5);
}

/* =========== File List Section =========== */
.file-list-section {
    margin: 2rem 0;
}

.file-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
}

.files-count {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1.125rem;
}

.btn-clear {
    background: var(--danger-color);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-clear:hover {
    background: #dc2626;
    transform: translateY(-1px);
}

.file-grid {
    display: grid;
    gap: 1rem;
}

.file-card {
    background: white;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: 1.5rem;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 1rem;
    align-items: center;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.file-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.file-card.completed {
    border-color: var(--success-color);
    background: rgba(16, 185, 129, 0.05);
}

.file-card.converting {
    border-color: var(--warning-color);
    background: rgba(245, 158, 11, 0.05);
}

.file-icon {
    font-size: 2rem;
    color: var(--primary-color);
}

.file-details {
    flex: 1;
}

.file-name {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    word-break: break-word;
}

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

.file-status {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.status-success, .status-converting, .status-pending {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
}

.status-success { color: var(--success-color); }
.status-converting { color: var(--warning-color); }
.status-pending { color: var(--text-secondary); }

.btn-download-single {
    background: var(--success-color);
    color: white;
    border: none;
    padding: 0.5rem;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-download-single:hover {
    background: #059669;
    transform: scale(1.1);
}

/* =========== Controls Section =========== */
.controls-section {
    display: grid;
    gap: 2rem;
    margin: 2rem 0;
    padding: 2rem;
    background: var(--secondary-color);
    border-radius: var(--border-radius-sm);
}

.quality-control {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.control-label {
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.quality-select {
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-size: 1rem;
    background: white;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.quality-select:focus {
    outline: none;
    border-color: var(--primary-color);
}

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

.btn-convert, .btn-download {
    padding: 1rem 2rem;
    border: none;
    border-radius: var(--border-radius-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1rem;
    box-shadow: var(--shadow);
}

.btn-convert {
    background: var(--primary-color);
    color: white;
    flex: 1;
    min-width: 200px;
}

.btn-convert:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 12px 20px -5px rgba(99, 102, 241, 0.4);
}

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

.btn-convert.converting {
    background: var(--warning-color);
}

.btn-download {
    background: var(--success-color);
    color: white;
}

.btn-download:hover {
    background: #059669;
    transform: translateY(-2px);
    box-shadow: 0 12px 20px -5px rgba(16, 185, 129, 0.4);
}

/* =========== Progress Section =========== */
.progress-section {
    background: white;
    border: 2px solid var(--primary-color);
    border-radius: var(--border-radius-sm);
    padding: 2rem;
    margin: 2rem 0;
}

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

.progress-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.progress-counter {
    color: var(--text-secondary);
    font-weight: 500;
}

.progress-bar-container {
    margin-bottom: 1rem;
}

.progress-bar {
    width: 100%;
    height: 12px;
    background: var(--border-color);
    border-radius: 6px;
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--primary-hover));
    border-radius: 6px;
    transition: width 0.3s ease;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 60px;
}

.progress-percent {
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.progress-status {
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
}

/* =========== Features Grid =========== */
.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-top: 3rem;
}

.feature-card {
    background: white;
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    text-align: center;
    transition: transform 0.3s ease;
    border: 1px solid var(--border-color);
}

.feature-card:hover {
    transform: translateY(-5px);
}

.feature-icon {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.feature-card h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 1rem 0;
}

.feature-card p {
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.6;
}

/* =========== Responsive Design =========== */
@media (max-width: 768px) {
    .brand-title {
        font-size: 2.5rem;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .conversion-card {
        padding: 1.5rem;
    }
    
    .main-container {
        padding: 0 1rem 4rem;
    }
    
    .file-card {
        grid-template-columns: 1fr;
        text-align: center;
        gap: 1rem;
    }
    
    .file-list-header {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    .progress-header {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;
    }
    
    .controls-section {
        padding: 1.5rem;
    }
    
    .features-grid {
        grid-template-columns: 1fr;
    }
}

/* =========== Animations =========== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.conversion-card, .feature-card {
    animation: fadeIn 0.6s ease forwards;
}

.feature-card:nth-child(1) { animation-delay: 0.1s; }
.feature-card:nth-child(2) { animation-delay: 0.2s; }
.feature-card:nth-child(3) { animation-delay: 0.3s; }

/* =========== Blazor Specific =========== */
#blazor-error-ui {
    background: var(--danger-color);
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
    color: white;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

.loading-progress {
    position: relative;
    display: block;
    width: 8rem;
    height: 8rem;
    margin: 20vh auto 1rem auto;
}

.loading-progress circle {
    fill: none;
    stroke: #e0e0e0;
    stroke-width: 0.6rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: var(--primary-color);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
    color: var(--text-primary);
}

.loading-progress-text:after {
    content: var(--blazor-load-percentage-text, "Loading");
}

/* =========== PWA Offline Support =========== */
.offline-indicator {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--warning-color);
    color: white;
    padding: 0.75rem;
    text-align: center;
    font-weight: 600;
    transform: translateY(-100%);
    transition: transform 0.3s ease;
    z-index: 9999;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.offline-indicator.show {
    transform: translateY(0);
}

.pwa-install-button {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50px;
    padding: 1rem 1.5rem;
    font-weight: 600;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    transition: all 0.3s ease;
    display: none;
    align-items: center;
    gap: 0.5rem;
    z-index: 1000;
}

.pwa-install-button:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

.pwa-install-button.show {
    display: flex;
}

.update-available-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--success-color);
    color: white;
    padding: 1rem;
    text-align: center;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
}

.update-available-banner.show {
    transform: translateY(0);
}

.update-button {
    background: white;
    color: var(--success-color);
    border: none;
    border-radius: var(--border-radius-sm);
    padding: 0.5rem 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.update-button:hover {
    opacity: 0.9;
    transform: scale(1.05);
}

/* =========== PWA App Icon =========== */
.app-icon {
    width: 64px;
    height: 64px;
    border-radius: 12px;
    object-fit: cover;
    box-shadow: var(--shadow);
}

/* =========== Loading States for PWA =========== */
.pwa-loading {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

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