/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Typography and Base Styles */
body {
    font-family: Arial, sans-serif;
    line-height: 1.6;
    background-color: #f5f5f5;
    color: #333;
    min-height: 100vh;
}

/* Layout */
.container {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1rem;
}

h1 {
    text-align: center;
    color: #2c3e50;
    margin-bottom: 2rem;
    font-size: 2.5rem;
}

h2 {
    color: #34495e;
    margin-bottom: 1.5rem;
    font-size: 1.8rem;
}

/* Sections */
.converter-section {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Form Elements */
.converter-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

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

/* Upload Method Toggle */
.upload-method-toggle {
    display: flex;
    gap: 1rem;
    margin-top: 0.5rem;
}

.method-option {
    display: flex !important;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    padding: 0.75rem 1rem;
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    transition: all 0.3s ease;
    user-select: none;
    font-weight: 500;
}

.method-option:hover {
    background: #e9ecef;
    border-color: #dee2e6;
}

.method-option input[type="radio"] {
    margin: 0;
}

.method-option input[type="radio"]:checked + span {
    color: #3498db;
    font-weight: 600;
}

.method-option:has(input[type="radio"]:checked) {
    background: #e3f2fd;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

/* URL Input Styles */
input[type="url"] {
    padding: 0.75rem;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 1rem;
    width: 100%;
    transition: border-color 0.3s, box-shadow 0.3s;
}

input[type="url"]:focus {
    border-color: #3498db;
    outline: none;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

.load-url-btn {
    background-color: #2ecc71;
    color: white;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    margin-top: 0.5rem;
    width: fit-content;
    transition: all 0.3s;
}

.load-url-btn:hover {
    background-color: #27ae60;
    transform: translateY(-1px);
}

.load-url-btn:active {
    transform: translateY(0);
}

/* URL Loading Status */
.url-status {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: #e3f2fd;
    border: 1px solid #bbdefb;
    border-radius: 6px;
    color: #1565c0;
    font-weight: 500;
}

.loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #bbdefb;
    border-top: 2px solid #1565c0;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* URL Preview */
.url-preview {
    background: linear-gradient(135deg, #e8f5e8 0%, #f0f8f0 100%);
    border: 2px solid #27ae60;
    border-radius: 8px;
    padding: 1.5rem;
    margin: 1rem 0;
    box-shadow: 0 2px 8px rgba(39, 174, 96, 0.1);
}

.url-preview .preview-info h4 {
    color: #27ae60;
    margin-bottom: 1rem;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.url-preview .image-details {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

.url-preview .image-details span {
    background: white;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    border: 1px solid #d4edda;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.url-preview .image-details strong {
    color: #2c3e50;
    font-weight: 600;
}

.url-note {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 6px;
    padding: 0.75rem;
    color: #856404 !important;
    font-size: 0.9rem !important;
    font-style: italic !important;
    margin-top: 1rem !important;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.url-note::before {
    content: "ℹ️";
    font-style: normal;
}

/* Labels and Inputs */
label {
    font-weight: 600;
    color: #2c3e50;
    font-size: 1rem;
}

.help-text {
    color: #666;
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

input[type="file"],
input[type="text"],
select {
    padding: 0.75rem;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.3s, box-shadow 0.3s;
}

input[type="text"],
select {
    width: 100%;
    max-width: 300px;
}

input[type="file"] {
    background: #f8f9fa;
    cursor: pointer;
}

input[type="text"]:focus,
select:focus {
    border-color: #3498db;
    outline: none;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

/* Checkbox and Radio Styles */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    user-select: none;
}

input[type="checkbox"],
input[type="radio"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* Buttons */
button {
    background-color: #3498db;
    color: white;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s;
}

button:hover {
    background-color: #2980b9;
    transform: translateY(-1px);
}

button:active {
    transform: translateY(0);
}

.download-btn {
    background-color: #27ae60;
    margin-top: 1rem;
}

.download-btn:hover {
    background-color: #219a52;
}

/* Resize Options */
.resize-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.resize-options div {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.resize-options input[type="text"] {
    width: 150px;
}

.resize-options input[type="text"]:disabled {
    background-color: #f5f5f5;
    cursor: not-allowed;
    opacity: 0.7;
}

/* Cropper Interface */
.cropper-container {
    margin: 1rem 0;
    max-width: 100%;
    min-height: 300px;
    max-height: 80vh;
    height: auto;
    background: #f8f9fa;
    border-radius: 6px;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
}

.cropper-container img {
    max-width: 100%;
    max-height: 100%;
}

/* Aspect Ratio Controls */
.aspect-ratio-controls {
    display: flex;
    gap: 1.5rem;
    padding: 1rem;
    background: #f8f9fa;
    border-top: 1px solid #eee;
    position: relative;
    bottom: 0;
    width: 100%;
    z-index: 100;
}

.aspect-ratio-controls label {
    display: flex !important;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    color: #000 !important;
    font-weight: 500 !important;
    padding: 0.5rem 1rem;
    background: white;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    opacity: 1 !important;
    visibility: visible !important;
    user-select: none;
}

/* Preview Containers */
.preview-container {
    margin: 1rem auto;
    text-align: center;
    max-width: 800px;
}

/* Cropper Preview */
.cropper-container .preview-container {
    flex: 1;
    position: relative;
    min-height: 300px;
    max-height: calc(80vh - 60px);
    width: 100%;
}

.cropper-container .preview-container img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
}

/* Output Preview */
#imagePreview .preview-container {
    max-height: calc(100vh - 200px);
    overflow: hidden;
}

#imagePreview .preview-container img {
    max-width: 100%;
    max-height: calc(100vh - 250px);
    margin: 0 auto 1rem;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    object-fit: contain;
}

/* Progress Bar */
.progress-bar {
    background-color: #ecf0f1;
    border-radius: 6px;
    height: 20px;
    margin-top: 1rem;
    overflow: hidden;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
}

.progress-bar .progress {
    background-color: #2ecc71;
    height: 100%;
    width: 0;
    transition: width 0.3s ease;
    border-radius: 6px;
}

/* Status Messages */
.status {
    padding: 1rem;
    border-radius: 6px;
    margin-top: 1rem;
    font-weight: 500;
    white-space: pre-line; /* Allow line breaks in error messages */
    line-height: 1.5;
}

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

.status.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    max-width: 100%;
    word-wrap: break-word;
}

/* Loading State */
.loading {
    opacity: 0.7;
    pointer-events: none;
    position: relative;
}

.loading::after {
    content: '';
    position: absolute;
    top: calc(50% - 1rem);
    left: calc(50% - 1rem);
    width: 2rem;
    height: 2rem;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Cropper Plugin Customization */
.cropper-view-box {
    outline-color: #3498db !important;
}

.cropper-line {
    background-color: #3498db !important;
}

.cropper-point {
    background-color: #3498db !important;
}

.cropper-face {
    background-color: #3498db !important;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Focus Styles */
*:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.4);
}

/* Responsive Design */
@media (max-width: 600px) {
    .container {
        margin: 1rem auto;
        padding: 0 0.75rem;
    }
    
    .converter-section {
        padding: 1rem;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    h2 {
        font-size: 1.5rem;
    }
    
    button {
        width: 100%;
    }
    
    .load-url-btn {
        width: 100%;
    }
    
    .upload-method-toggle {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .method-option {
        justify-content: center;
        text-align: center;
    }
    
    .aspect-ratio-controls {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .resize-options div {
        flex-direction: column;
        align-items: flex-start;
    }
    
    input[type="text"],
    input[type="url"],
    select {
        max-width: 100%;
    }
    
    .cropper-container {
        height: 300px;
    }
    
    #imagePreview .preview-container img {
        max-height: calc(100vh - 300px);
    }
    
    .url-preview .image-details {
        flex-direction: column;
        gap: 0.5rem;
    }
}

/* Image Info Styles */
.image-info {
    display: flex;
    gap: 2rem;
    margin: 1rem 0;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #e9ecef;
}

.info-section {
    flex: 1;
}

.info-section h3 {
    color: #2c3e50;
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.info-section p {
    margin: 0.25rem 0;
    color: #495057;
}

@media (max-width: 600px) {
    .image-info {
        flex-direction: column;
        gap: 1rem;
    }
}

/* Add side by side layout */
.converter-wrapper {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
}

.converter-section {
    flex: 1;
    min-width: 0; /* Prevent flex items from overflowing */
}

/* Responsive design for mobile */
@media (max-width: 900px) {
    .converter-wrapper {
        flex-direction: column;
        gap: 1rem;
    }
    
    .converter-section {
        width: 100%;
    }
}

/* Video Preview Styles */
#videoPreviewContainer {
    margin: 1.5rem 0;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 1rem;
    text-align: center;
}

#videoPreviewContainer video {
    max-width: 100%;
    max-height: 400px;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Video Information Styles */
.video-info {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 1rem;
    margin: 1rem 0;
}

.video-info .info-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.video-info h3 {
    color: #2c3e50;
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
    grid-column: 1 / -1;
}

.video-info p {
    margin: 0.25rem 0;
    color: #495057;
}

/* Dimension Controls */
.dimension-controls {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

.dimension-presets,
.custom-dimensions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

#dimensionPresets {
    padding: 0.75rem;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 1rem;
    background-color: white;
    cursor: pointer;
    transition: border-color 0.3s, box-shadow 0.3s;
}

#dimensionPresets:focus {
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

/* Loading State Enhancement */
.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

/* Progress Bar Enhancement */
.progress-bar .progress {
    position: relative;
    overflow: hidden;
}

.progress-bar .progress::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.2),
        transparent
    );
    animation: progress-animation 1.5s linear infinite;
}

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

/* Responsive Adjustments */
@media (max-width: 600px) {
    .dimension-controls {
        grid-template-columns: 1fr;
    }
    
    .video-info .info-section {
        grid-template-columns: 1fr;
    }
    
    #videoPreviewContainer video {
        max-height: 300px;
    }
}

/* Video Info Comparison Styles */
.video-info {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 1.5rem;
    margin: 1.5rem 0;
}

.info-comparison {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 1.5rem;
}

.info-section {
    background: white;
    border-radius: 6px;
    padding: 1.25rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.info-section h3 {
    color: #2c3e50;
    font-size: 1.1rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #e9ecef;
}

.info-content p {
    margin: 0.5rem 0;
    color: #495057;
    line-height: 1.5;
}

.info-content strong {
    color: #2c3e50;
    font-weight: 600;
    min-width: 100px;
    display: inline-block;
}

.comparison-summary {
    background: #e8f4f8;
    border-radius: 6px;
    padding: 1.25rem;
    margin-top: 1rem;
}

.comparison-summary h3 {
    color: #2c3e50;
    font-size: 1.1rem;
    margin-bottom: 1rem;
}

.summary-content p {
    margin: 0.5rem 0;
    color: #2c3e50;
    font-weight: 500;
}

.converted-info {
    position: relative;
}

.converted-info::before {
    content: '→';
    position: absolute;
    left: -1.5rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.5rem;
    color: #3498db;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .info-comparison {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .converted-info::before {
        content: '↓';
        left: 50%;
        top: -1.5rem;
        transform: translateX(-50%);
    }
}

/* Loading State */
.info-section.loading {
    position: relative;
}

.info-section.loading::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 6px;
}

/* Format & Quality Row */
.format-quality-row {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
}

.format-container,
.quality-container {
    flex: 1;
    min-width: 0;
}

.format-container select,
.quality-container select {
    width: 100%;
}

@media (max-width: 600px) {
    .format-quality-row {
        flex-direction: column;
        gap: 1rem;
    }
    
    .format-container,
    .quality-container {
        width: 100%;
    }
}

/* Format and Quality Container */
.format-quality-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 1.5rem;
}

.format-section,
.quality-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.select-with-help {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.select-with-help select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.help-text {
    font-size: 0.875rem;
    color: #666;
    margin-top: 0.25rem;
}

/* Dimensions Container */
.dimensions-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-top: 1rem;
}

.dimensions-section,
.common-dimensions-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.dimensions-section input,
.common-dimensions-section select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .format-quality-container,
    .dimensions-container {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
}

/* Dimensions Layout */
.dimensions-row {
    display: flex;
    gap: 2rem;
    margin: 1rem 0;
}

.dimension-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.dimension-group input,
.dimension-group select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

.dimension-group .help-text {
    font-size: 0.875rem;
    color: #666;
}

/* Responsive Design */
@media (max-width: 600px) {
    .dimensions-row {
        flex-direction: column;
        gap: 1rem;
    }
}

.dimensions-row {
    display: flex;
    gap: 2rem;
    margin: 1rem 0;
    align-items: flex-end; /* Aligns items at the bottom */
}

.dimension-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Add spacing at the top of the dropdown to align with input */
.dimension-group.no-label {
    margin-top: 1.5rem; /* Compensates for missing label */
}

.dimension-group input,
.dimension-group select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

.dimension-group .help-text {
    font-size: 0.875rem;
    color: #666;
    margin-top: 0.25rem;
}

/* Responsive Design */
@media (max-width: 600px) {
    .dimensions-row {
        flex-direction: column;
        gap: 1rem;
    }
    
    .dimension-group.no-label {
        margin-top: 0; /* Reset margin on mobile */
    }
}

.dimension-group {
    margin: 1rem 0;
}

.dimension-input-container {
    max-width: 300px; /* Or your preferred width */
}

.dimension-group input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

.dimension-group .help-text {
    display: block;
    font-size: 0.875rem;
    color: #666;
    margin-top: 0.25rem;
}

/* Add these styles to your existing style.css file */

/* Video Preview Styles */
#convertedVideoPreview {
    margin: 1.5rem 0;
}

#convertedVideoPreview video {
    width: 100%;
    max-width: 100%;
    border-radius: 0.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#convertedVideoPreview .download-button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

#convertedVideoPreview .download-button:hover {
    background-color: #2980b9;
    transform: translateY(-1px);
}

#convertedVideoPreview .download-button:active {
    transform: translateY(0);
}

/* Video Container Enhancement */
.video-preview-container {
    background: white;
    border-radius: 0.5rem;
    padding: 1rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin: 1rem 0;
}

.video-preview-container h3 {
    color: #2c3e50;
    font-size: 1.25rem;
    margin-bottom: 1rem;
    text-align: center;
}

/* Video Controls Enhancement */
.video-preview-container video::-webkit-media-controls {
    background-color: rgba(0, 0, 0, 0.5);
}

.video-preview-container video::-webkit-media-controls-panel {
    padding: 0 0.5rem;
}

/* Loading State for Video */
.video-loading {
    position: relative;
}

.video-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}