/* Prevent horizontal scrolling on mobile */
html, body {
    overflow-x: hidden;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    background: white;
    border-radius: 15px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 40px 30px;
    text-align: center;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    font-weight: 300;
}

header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

main {
    padding: 40px 30px;
}

.input-section {
    display: flex;
    gap: 15px;
    margin-bottom: 30px;
}

#mediaUrl {
    flex: 1;
    padding: 15px 20px;
    border: 2px solid #e1e5e9;
    border-radius: 10px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
    background: white;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

#mediaUrl:focus {
    outline: none;
    border-color: #667eea;
}

#extractBtn {
    padding: 15px 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease;
}

#extractBtn:hover {
    transform: translateY(-2px);
}

#extractBtn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.loading {
    text-align: center;
    padding: 40px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.media-info {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 30px;
    margin-bottom: 20px;
}

.media-preview {
    display: flex;
    gap: 20px;
    margin-bottom: 30px;
    align-items: center;
}

#thumbnail {
    width: 120px;
    height: 90px;
    object-fit: cover;
    border-radius: 10px;
    background: #e1e5e9;
}

.media-details h3 {
    font-size: 1.3rem;
    margin-bottom: 10px;
    color: #333;
}

.media-details p {
    color: #666;
    margin-bottom: 5px;
}

.action-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 15px 20px;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.action-btn.download {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
}

.action-btn.telegram {
    background: linear-gradient(135deg, #0088cc 0%, #0099dd 100%);
    color: white;
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

.action-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.action-btn .icon {
    font-size: 1.2rem;
}

.message {
    padding: 15px 20px;
    border-radius: 10px;
    margin-top: 20px;
    font-weight: 500;
}

.message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.download-section {
    margin-top: 30px;
    padding: 20px;
    background: #f0f8ff;
    border-radius: 10px;
    border: 2px solid #e1e5e9;
}

.download-item {
    display: flex;
    flex-direction: column;
    padding: 20px 0;
    border-bottom: 1px solid #e1e5e9;
}

.download-item:last-child {
    border-bottom: none;
}

.download-header {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 15px;
}

.download-status {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.download-status .icon {
    font-size: 1.2rem;
}

.download-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.download-options {
    margin-top: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.option-group {
    margin-bottom: 15px;
}

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

.option-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #495057;
    font-size: 0.9rem;
}

.option-group input,
.option-group textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color 0.3s ease;
    resize: vertical;
}

.option-group input:focus,
.option-group textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

.option-group textarea {
    min-height: 60px;
    line-height: 1.4;
}

.help-text {
    display: block;
    margin-top: 5px;
    font-size: 0.8rem;
    color: #6c757d;
    font-style: italic;
}

.date-selector {
    display: flex;
    gap: 10px;
}

.date-selector select {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: inherit;
    background-color: white;
    transition: border-color 0.3s ease;
}

.date-selector select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.checkbox-group input[type="checkbox"] {
    width: auto;
    margin: 0;
}

.checkbox-group label {
    margin: 0;
    font-weight: normal;
    cursor: pointer;
}

.download-ready-btn {
    padding: 10px 20px;
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 120px;
}

.download-ready-btn.telegram-btn {
    background: linear-gradient(135deg, #0088cc 0%, #0099dd 100%);
}

.download-ready-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.download-ready-btn:disabled {
    background: #6c757d;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.download-ready-btn.ready {
    animation: pulse 2s infinite;
}

.download-ready-btn.telegram-btn.ready {
    animation: pulse-telegram 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(40, 167, 69, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(40, 167, 69, 0);
    }
}

@keyframes pulse-telegram {
    0% {
        box-shadow: 0 0 0 0 rgba(0, 136, 204, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(0, 136, 204, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(0, 136, 204, 0);
    }
}

/* Progress Bar Styles */
.download-progress {
    margin-top: 15px;
    padding: 20px;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    border-radius: 12px;
    border: 2px solid #e2e8f0;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    width: 100%;
    box-sizing: border-box;
    position: relative;
    clear: both;
}

.download-progress:not(.hidden) {
    animation: slideDown 0.3s ease-out;
}

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

.progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-size: 0.9rem;
    color: #374151;
}

.progress-text {
    font-weight: 500;
    flex: 1;
}

.progress-percentage {
    font-weight: 700;
    color: #667eea;
    font-size: 1rem;
    min-width: 50px;
    text-align: right;
}

.progress-bar {
    width: 100%;
    height: 12px;
    background: #e5e7eb;
    border-radius: 6px;
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    border-radius: 6px;
    width: 0%;
    transition: width 0.3s ease;
    position: relative;
    box-shadow: 0 2px 4px rgba(102, 126, 234, 0.3);
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.3) 50%,
        transparent 100%
    );
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

/* Enhanced button interactions for touch devices */
.action-btn,
.download-ready-btn {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
}

.action-btn:active,
.download-ready-btn:active {
    transform: translateY(0);
    transition: none;
}

/* Better focus states for accessibility */
.action-btn:focus,
.download-ready-btn:focus,
#extractBtn:focus,
#mediaUrl:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* Enhanced visibility for progress bars */
.download-progress.visible {
    border-color: #667eea;
    box-shadow: 0 8px 25px -5px rgba(102, 126, 234, 0.2);
    background: linear-gradient(135deg, #f0f4ff 0%, #e0e7ff 100%);
}

/* Improved container max-width for better desktop experience */
.container {
    max-width: 900px;
}

/* Better spacing for desktop */
@media (min-width: 769px) {
    .download-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        gap: 20px;
    }
    
    .download-actions {
        flex-shrink: 0;
    }
}

/* Preparation Progress Bars */
.preparation-progress-section {
    margin-top: 20px;
}

.preparation-progress {
    margin-bottom: 15px;
    padding: 20px;
    background: linear-gradient(135deg, #fff7ed 0%, #fed7aa 100%);
    border-radius: 12px;
    border: 2px solid #fb923c;
    box-shadow: 0 4px 6px -1px rgba(251, 146, 60, 0.2);
    transition: all 0.3s ease;
    width: 100%;
    box-sizing: border-box;
    position: relative;
    clear: both;
}

.preparation-progress:not(.hidden) {
    animation: slideDown 0.3s ease-out;
}

.preparation-progress .progress-header {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
    font-weight: 600;
    color: #ea580c;
}

.preparation-progress .progress-header .icon {
    margin-right: 8px;
    font-size: 1.1rem;
}

.preparation-progress .progress-title {
    font-size: 1rem;
}

.preparation-progress .progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-size: 0.9rem;
    color: #9a3412;
}

.preparation-progress .progress-text {
    font-weight: 500;
    flex: 1;
}

.preparation-progress .progress-percentage {
    font-weight: 700;
    color: #ea580c;
    font-size: 1rem;
    min-width: 50px;
    text-align: right;
}

.preparation-progress .progress-bar {
    width: 100%;
    height: 12px;
    background: #fed7aa;
    border-radius: 6px;
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.preparation-progress .progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #fb923c 0%, #ea580c 100%);
    border-radius: 6px;
    width: 0%;
    transition: width 0.5s ease;
    position: relative;
    box-shadow: 0 2px 4px rgba(251, 146, 60, 0.4);
}

.preparation-progress .progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.4) 50%,
        transparent 100%
    );
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .container {
        margin: 0;
        border-radius: 10px;
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    }
    
    header {
        padding: 25px 20px;
    }
    
    header h1 {
        font-size: 1.8rem;
        line-height: 1.2;
    }
    
    header p {
        font-size: 1rem;
        line-height: 1.4;
    }
    
    main {
        padding: 25px 20px;
    }
    
    .input-section {
        flex-direction: column;
        gap: 12px;
    }
    
    #mediaUrl {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 12px 16px;
    }
    
    #extractBtn {
        padding: 12px 24px;
        font-size: 1rem;
    }
    
    .media-preview {
        flex-direction: column;
        text-align: center;
        gap: 15px;
    }
    
    #thumbnail {
        width: 100%;
        max-width: 200px;
        height: auto;
        aspect-ratio: 16/9;
    }
    
    .media-details h3 {
        font-size: 1.1rem;
        line-height: 1.3;
    }
    
    .action-buttons {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .action-btn {
        padding: 12px 16px;
        font-size: 0.95rem;
    }
    
    /* Download section mobile optimization */
    .download-section {
        padding: 15px;
        margin-top: 20px;
    }
    
    .download-item {
        padding: 15px 0;
    }
    
    .download-header {
        gap: 12px;
    }
    
    .download-actions {
        justify-content: stretch;
    }
    
    .download-ready-btn {
        flex: 1;
        min-width: 0;
        padding: 10px 12px;
        font-size: 0.85rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    /* Progress bar mobile optimization */
    .download-progress {
        margin-top: 12px;
        padding: 15px;
        border-radius: 10px;
    }
    
    .preparation-progress {
        margin-bottom: 12px;
        padding: 15px;
        border-radius: 10px;
    }
    
    .progress-info {
        font-size: 0.8rem;
        margin-bottom: 10px;
    }
    
    .progress-percentage {
        font-size: 0.9rem;
        min-width: 45px;
    }
    
    .progress-bar {
        height: 10px;
    }
    
    /* Form elements mobile optimization */
    .download-options {
        margin-top: 12px;
        padding: 12px;
    }
    
    .option-group {
        margin-bottom: 12px;
    }
    
    .option-group input,
    .option-group textarea,
    .option-group select {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 10px 12px;
    }
    
    .date-selector {
        flex-direction: column;
        gap: 8px;
    }
    
    .date-selector select {
        flex: none;
    }
    
    /* Message optimization */
    .message {
        padding: 12px 16px;
        font-size: 0.9rem;
        margin-top: 15px;
    }
    
    /* Preparation progress mobile specific */
    .preparation-progress .progress-header {
        margin-bottom: 10px;
    }
    
    .preparation-progress .progress-title {
        font-size: 0.9rem;
    }
    
    .preparation-progress .progress-info {
        font-size: 0.8rem;
        margin-bottom: 8px;
    }
}

/* Extra small screens (phones in portrait) */
@media (max-width: 480px) {
    body {
        padding: 5px;
    }
    
    header h1 {
        font-size: 1.6rem;
    }
    
    header p {
        font-size: 0.9rem;
    }
    
    main {
        padding: 20px 15px;
    }
    
    .download-actions {
        flex-direction: column;
    }
    
    .download-ready-btn {
        flex: none;
        width: 100%;
    }
    
    .action-btn {
        padding: 14px 16px;
    }
    
    .progress-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
    
    .progress-percentage {
        align-self: flex-end;
    }
    
    .date-selector {
        gap: 6px;
    }
}
.hidden {
    display: none;
}