/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #333;
}

.container {
    max-width: 600px;
    width: 100%;
    padding: 20px;
}

/* Header */
header {
    margin-bottom: 30px;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-content > div {
    flex: 1;
}

header h1 {
    color: white;
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

header p {
    color: rgba(255,255,255,0.9);
    font-size: 1.1rem;
}

.gallery-btn {
    background: rgba(255,255,255,0.1);
    border: 2px solid rgba(255,255,255,0.3);
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.gallery-btn:hover {
    background: rgba(255,255,255,0.2);
    border-color: rgba(255,255,255,0.5);
    transform: translateY(-1px);
}

/* Upload Area */
.upload-area {
    background: white;
    border-radius: 12px;
    padding: 40px 30px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
    border: 2px dashed #ddd;
    margin-bottom: 20px;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: #667eea;
    background: #f8f9ff;
}

.upload-content {
    display: block;
}

.upload-icon {
    font-size: 3rem;
    margin-bottom: 20px;
}

.upload-area h3 {
    font-size: 1.5rem;
    margin-bottom: 10px;
    color: #333;
}

.upload-area p {
    color: #666;
    font-size: 1rem;
}

.file-link {
    color: #667eea;
    cursor: pointer;
    text-decoration: underline;
}

.file-link:hover {
    color: #764ba2;
}

/* Progress */
.upload-progress {
    margin-top: 20px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #eee;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    width: 0%;
    transition: width 0.3s ease;
}

#progressText {
    color: #666;
    font-size: 0.9rem;
}

/* Results */
.results {
    background: white;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    text-align: center;
}

.results h3 {
    color: #28a745;
    margin-bottom: 20px;
    font-size: 1.3rem;
}

/* Image Preview */
.image-preview {
    margin: 20px 0;
}

.image-preview img {
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* URL Section */
.url-section {
    margin: 20px 0;
}

.url-section label {
    display: block;
    font-weight: bold;
    margin-bottom: 8px;
    color: #333;
}

.url-input-group {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

#imageUrl {
    flex: 1;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    background: #f8f9fa;
}

.copy-btn {
    padding: 12px 16px;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s ease;
}

.copy-btn:hover {
    background: #218838;
}

.copy-btn.copied {
    background: #17a2b8;
}

/* Image Info */
.image-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin: 20px 0;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
}

.info-item {
    text-align: center;
}

.info-label {
    display: block;
    font-weight: bold;
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 4px;
}

/* Actions */
.actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 25px;
}

.btn-primary, .btn-secondary {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #764ba2;
    transform: translateY(-1px);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-1px);
}

/* Error */
.error {
    background: white;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    text-align: center;
    border-left: 4px solid #dc3545;
}

.error-icon {
    font-size: 2rem;
    margin-bottom: 15px;
}

.error h3 {
    color: #dc3545;
    margin-bottom: 10px;
}

.error p {
    color: #666;
    margin-bottom: 20px;
}

/* Footer */
footer {
    text-align: center;
    margin-top: 30px;
    color: rgba(255,255,255,0.8);
    font-size: 0.9rem;
}

/* Gallery View */
.gallery {
    background: white;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.gallery-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid #eee;
    padding-bottom: 15px;
}

.gallery-header h3 {
    color: #333;
    margin: 0;
}

.back-btn {
    background: #6c757d;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s ease;
}

.back-btn:hover {
    background: #5a6268;
}

.gallery-stats {
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    text-align: center;
    color: #666;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.gallery-item {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.gallery-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
}

.gallery-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
}

.gallery-info {
    padding: 15px;
}

.gallery-filename {
    font-weight: bold;
    color: #333;
    margin-bottom: 5px;
    font-size: 14px;
    word-break: break-all;
}

.gallery-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: #666;
    margin-bottom: 10px;
}

.gallery-actions {
    display: flex;
    gap: 8px;
}

.gallery-actions button {
    flex: 1;
    padding: 8px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.copy-url-btn {
    background: #28a745;
    color: white;
}

.copy-url-btn:hover {
    background: #218838;
}

.delete-btn {
    background: #dc3545;
    color: white;
}

.delete-btn:hover {
    background: #c82333;
}

/* Delete confirmation modal */
.delete-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.delete-modal-content {
    background: white;
    padding: 30px;
    border-radius: 12px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.delete-modal-content h3 {
    color: #dc3545;
    margin-bottom: 15px;
}

.delete-modal-content p {
    color: #666;
    margin-bottom: 25px;
}

.delete-modal-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.delete-modal-actions button {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
}

.cancel-delete {
    background: #6c757d;
    color: white;
}

.cancel-delete:hover {
    background: #5a6268;
}

.confirm-delete {
    background: #dc3545;
    color: white;
}

.confirm-delete:hover {
    background: #c82333;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }

    .header-content {
        flex-direction: column;
        gap: 20px;
        text-align: center;
    }

    header h1 {
        font-size: 2rem;
    }

    .upload-area {
        padding: 30px 20px;
    }

    .url-input-group {
        flex-direction: column;
    }

    .actions {
        flex-direction: column;
    }

    .image-info {
        grid-template-columns: 1fr;
    }

    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 15px;
    }

    .gallery-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    .gallery-meta {
        flex-direction: column;
        gap: 5px;
        align-items: flex-start;
    }

    .gallery-actions {
        flex-direction: column;
    }

    .delete-modal-actions {
        flex-direction: column;
    }
}

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

.results, .error {
    animation: fadeIn 0.3s ease-out;
}

/* Loading spinner */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 10px;
}

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