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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    position: relative;
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('images/image-28.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    z-index: -2;
    pointer-events: none;
}

body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    z-index: -1;
    pointer-events: none;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    position: relative;
    z-index: 1;
}

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

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
}

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

main {
    padding: 40px;
}

/* Tab Navigation */
.tab-navigation {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    border-bottom: 3px solid #e0e0e0;
    flex-wrap: nowrap;                /* single row by default */
    overflow-x: visible;              /* no horizontal scroll in wide view */
}

.tab-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 15px 24px;
    font-size: 1em;
    font-weight: 600;
    color: #666;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;              /* prevent wrapping inside a button */
    flex: 0 0 auto;                   /* don't stretch/shrink into multiple rows */
    position: relative;
    bottom: -3px;
}

.tab-btn:hover {
    color: #667eea;
    background: rgba(102, 126, 234, 0.05);
}

.tab-btn.active {
    color: #667eea;
    border-bottom-color: #667eea;
    background: rgba(102, 126, 234, 0.1);
}

.tab-btn span:first-child {
    font-size: 1.2em;
}

/* Tab Content */
.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

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

.tab-description {
    background: linear-gradient(135deg, #f8f9ff 0%, #f0f2ff 100%);
    padding: 25px;
    border-radius: 12px;
    margin-bottom: 30px;
    border-left: 4px solid #667eea;
}

.tab-description h2 {
    color: #667eea;
    font-size: 1.8em;
    margin-bottom: 12px;
}

.tab-description p {
    color: #555;
    font-size: 1.05em;
    line-height: 1.7;
    margin: 0;
}

.platform-selector {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.platform-btn {
    padding: 10px 20px;
    font-size: 0.95em;
    font-weight: 600;
    color: #667eea;
    background: white;
    border: 2px solid #667eea;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.platform-btn:hover {
    background: #f0f2ff;
}

.platform-btn.active {
    color: white;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: #667eea;
}

.ai-model-selector {
    margin: 20px 0;
}

.ai-model-selector h4 {
    margin-bottom: 15px;
    color: #333;
    font-size: 1.1em;
    text-align: center;
}

.ai-model-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 15px;
}

.ai-model-item {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ai-model-btn {
    padding: 15px 16px;
    font-size: 0.95em;
    font-weight: 600;
    color: #667eea;
    background: white;
    border: 2px solid #667eea;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    width: 100%;
}

.ai-model-btn:hover {
    background: #f0f2ff;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.2);
}

.ai-model-btn.active {
    color: white;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.model-name {
    display: block;
    font-weight: 700;
}

.model-description {
    font-size: 0.85em;
    color: #666;
    line-height: 1.6;
    margin: 0;
    padding: 10px;
    background: #f8f9ff;
    border-radius: 6px;
    border-left: 3px solid #667eea;
    transition: all 0.3s ease;
}

.ai-model-item.selected .model-description {
    background: #f0f2ff;
    border-left-color: #764ba2;
    border-left-width: 4px;
    color: #333;
}

.mode-description {
    color: #666;
    font-size: 0.9em;
    margin-bottom: 20px;
}

.platform-hint {
    color: #666;
    font-size: 0.85em;
    text-align: center;
    margin-top: 10px;
    margin-bottom: 0;
}

.generate-hint {
    color: #666;
    font-size: 0.85em;
    text-align: center;
    margin-top: 15px;
    margin-bottom: 0;
}

.download-hint {
    color: #666;
    font-size: 0.85em;
    text-align: center;
    margin-top: 15px;
    margin-bottom: 0;
}

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

.upload-area {
    border: 3px dashed #667eea;
    border-radius: 15px;
    padding: 30px 20px 60px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #f8f9ff;
    background-image: url('images/image-27.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    position: relative;
}

.upload-area::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(248, 249, 255, 0.7);
    border-radius: 15px;
    z-index: 0;
}

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

.upload-area:hover {
    border-color: #764ba2;
    transform: translateY(-2px);
}

.upload-area:hover::before {
    background: rgba(240, 242, 255, 0.8);
}

.upload-area.dragover {
    border-color: #764ba2;
    transform: scale(1.02);
}

.upload-area.dragover::before {
    background: rgba(232, 235, 255, 0.85);
}

.upload-content svg {
    color: #667eea;
    margin-bottom: 15px;
}

.upload-content p {
    font-size: 1.2em;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
}

.file-info {
    color: #666;
    font-size: 0.9em;
}

.preview-section {
    margin-top: 30px;
}

.image-preview {
    margin-bottom: 30px;
}

.image-preview h3 {
    margin-bottom: 15px;
    color: #667eea;
    font-size: 1.3em;
}

.image-preview img {
    max-width: 100%;
    height: auto;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    display: block;
    margin: 0 auto;
}

/* Crop preview overlay */
.crop-preview-container {
    position: relative;
    display: inline-block;
    max-width: 100%;
    overflow: hidden; /* keep dark overlay inside the image area */
}

.crop-preview-container img {
    display: block;
    max-width: 100%;
    height: auto;
}

.crop-overlay {
    position: absolute;
    border: 2px dashed rgba(255, 255, 255, 0.9);
    box-shadow: 0 0 0 20000px rgba(0, 0, 0, 0.4);
    cursor: move;
    border-radius: 4px;
    pointer-events: auto;
    box-sizing: border-box;
}

.crop-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: #ffffff;
    border: 2px solid #667eea;
    border-radius: 50%;
    box-sizing: border-box;
}

.crop-handle.tl {
    top: -8px;
    left: -8px;
    cursor: nwse-resize;
}

.crop-handle.tr {
    top: -8px;
    right: -8px;
    cursor: nesw-resize;
}

.crop-handle.bl {
    bottom: -8px;
    left: -8px;
    cursor: nesw-resize;
}

.crop-handle.br {
    bottom: -8px;
    right: -8px;
    cursor: nwse-resize;
}

.file-info-display {
    margin-top: 15px;
    text-align: center;
    font-size: 0.95em;
    color: #666;
}

.file-info-display span {
    display: block;
    margin: 5px 0;
    padding: 8px 15px;
    background: #f0f2ff;
    border-radius: 8px;
    display: inline-block;
    margin: 5px;
}

.compression-options {
    margin: 30px 0;
    text-align: center;
}

.compression-options h3 {
    margin-bottom: 20px;
    color: #333;
    font-size: 1.3em;
}

.button-group {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.compress-btn {
    padding: 15px 30px;
    font-size: 1.1em;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.compress-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

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

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

.result-section {
    margin-top: 40px;
    padding-top: 40px;
    border-top: 2px solid #e0e0e0;
}

.download-btn {
    display: block;
    margin: 30px auto 0;
    padding: 15px 40px;
    font-size: 1.2em;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(17, 153, 142, 0.4);
}

.download-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(17, 153, 142, 0.6);
}

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

/* Footer Styles */
footer {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.8) 0%, rgba(118, 75, 162, 0.8) 100%);
    color: white;
    margin-top: 60px;
    padding: 40px 20px 20px 20px;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 30px;
    margin-bottom: 30px;
}

.footer-section {
    background: rgba(255, 255, 255, 0.1);
    padding: 25px;
    border-radius: 10px;
    backdrop-filter: blur(10px);
}

.footer-section h3 {
    margin-bottom: 15px;
    font-size: 1.2em;
    color: white;
}

.footer-section ul {
    list-style: none;
    padding: 0;
}

.footer-section ul li {
    margin-bottom: 10px;
    padding-left: 20px;
    position: relative;
    line-height: 1.6;
}

.footer-section ul li:before {
    content: "•";
    position: absolute;
    left: 0;
    color: white;
    font-weight: bold;
}

.footer-section p {
    line-height: 1.8;
    margin-bottom: 0;
}

.support-section {
    grid-column: 1 / -1;
}

.social-media {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
    margin: 20px 0;
}

.social-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.95em;
    font-weight: 600;
}

.social-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-2px);
}

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

.share-text {
    text-align: center;
    margin-top: 15px;
    font-size: 1em;
    font-weight: 600;
}

.footer-bottom {
    text-align: center;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.9em;
}

/* Below full width: allow tabs to wrap into two rows (e.g. 3 per row) */
@media (max-width: 1199px) {
    .tab-navigation {
        flex-wrap: wrap;
        gap: 8px;
    }

    .tab-btn {
        flex: 1 1 calc(33.33% - 8px);
        min-width: 0;
    }
}

@media (max-width: 1024px) {
    .tab-btn {
        padding: 12px 18px;
        font-size: 0.95em;
    }
}

@media (max-width: 768px) {
    header h1 {
        font-size: 2em;
    }

    main {
        padding: 20px;
    }

    .button-group {
        flex-direction: column;
    }

    .compress-btn {
        width: 100%;
    }

    .tab-btn {
        padding: 10px 14px;
        font-size: 0.9em;
    }

    .tab-description {
        padding: 20px;
    }

    .tab-description h2 {
        font-size: 1.5em;
    }

    .tab-description p {
        font-size: 0.95em;
    }

    .mode-buttons,
    .platform-selector {
        flex-direction: column;
    }

    .mode-btn,
    .platform-btn,
    .ai-model-btn {
        width: 100%;
    }
    
    .ai-model-buttons {
        grid-template-columns: 1fr;
    }

    .ai-model-item {
        width: 100%;
    }

    .footer-content {
        grid-template-columns: 1fr;
    }

    .support-section {
        grid-column: 1;
    }

    .social-media {
        flex-direction: column;
    }

    .social-btn {
        width: 100%;
        justify-content: center;
    }

    footer {
        padding: 30px 15px 15px 15px;
    }
}

/* Only on very small screens (<480px) allow tabs to wrap into 2 rows */
@media (max-width: 480px) {
    .tab-navigation {
        flex-wrap: wrap;
        gap: 6px;
        overflow-x: visible;
    }

    .tab-btn {
        flex: 1 1 45%;
        min-width: 0;
    }
}

#generatedFilesList {
    margin: 20px 0;
    padding: 15px;
    background: #f8f9ff;
    border-radius: 10px;
    max-height: 300px;
    overflow-y: auto;
}

#generatedFilesList .file-item {
    padding: 8px;
    margin: 5px 0;
    background: white;
    border-radius: 5px;
    font-size: 0.9em;
    color: #333;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.file-thumb {
    /* Size will be controlled inline from JS to reflect actual pixel size */
    max-width: 256px;
    max-height: 256px;
    object-fit: contain;
    border-radius: 4px;
    border: 1px solid #e0e0e0;
    background: #fff;
    flex-shrink: 0;
}

/* File List Styles */
.file-list-section {
    margin: 30px 0;
    padding: 20px;
    background: #f8f9ff;
    border-radius: 12px;
    border: 2px solid #e0e0e0;
}

.file-list-section h3 {
    margin-bottom: 10px;
    color: #667eea;
    font-size: 1.2em;
}

.file-list-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    margin: 10px 0;
    background: white;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    transition: all 0.3s ease;
}

.file-list-item:hover {
    border-color: #667eea;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.1);
}

.file-list-item .file-icon {
    font-size: 2em;
    flex-shrink: 0;
}

.file-list-item .file-info {
    flex: 1;
    min-width: 0;
}

.file-list-item .file-name {
    font-weight: 600;
    color: #333;
    margin-bottom: 5px;
    word-break: break-word;
}

.file-list-item .file-size {
    font-size: 0.85em;
    color: #666;
}

.file-list-item .file-rename {
    flex: 1;
    max-width: 300px;
}

.file-list-item .file-rename input {
    width: 100%;
    padding: 8px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 0.95em;
    transition: border-color 0.3s ease;
}

.file-list-item .file-rename input:focus {
    outline: none;
    border-color: #667eea;
}

.file-list-item .file-status {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85em;
    font-weight: 600;
    min-width: 80px;
    text-align: center;
}

.file-list-item .file-status.pending {
    background: #f0f0f0;
    color: #666;
}

.file-list-item .file-status.processing {
    background: #fff3cd;
    color: #856404;
}

.file-list-item .file-status.completed {
    background: #d4edda;
    color: #155724;
}

.file-list-item .file-status.error {
    background: #f8d7da;
    color: #721c24;
}

@media (max-width: 768px) {
    .file-list-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .file-list-item .file-rename {
        max-width: 100%;
        width: 100%;
    }
}


