/* Pet Emoji Generator Styles */
* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    margin: 0;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    justify-content: center;
}

.app-container {
    background: #ffffff;
    width: 100%;
    max-width: 900px;
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    padding: 40px;
    box-sizing: border-box;
}

/* Header */
h2 {
    text-align: center;
    color: #333;
    margin-bottom: 30px;
    font-size: 28px;
    font-weight: 700;
}

h2 .emoji {
    font-size: 32px;
    margin-right: 8px;
}

/* Code Input Section */
.code-section {
    margin-bottom: 25px;
}

.code-input-wrapper {
    display: flex;
    gap: 12px;
    margin-bottom: 10px;
}

.code-input {
    flex: 1;
    padding: 16px 20px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    font-size: 18px;
    text-align: center;
    letter-spacing: 4px;
    text-transform: uppercase;
    transition: all 0.3s ease;
}

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

.code-input:disabled {
    background: #f5f5f5;
    cursor: not-allowed;
}

.btn-verify {
    padding: 16px 32px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.btn-verify:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.3);
}

.btn-verify:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.code-status {
    text-align: center;
    font-size: 14px;
    min-height: 20px;
}

.code-status.success {
    color: #07C160;
}

.code-status.error {
    color: #ff4d4f;
}

/* Upload Section */
.upload-section {
    border: 3px dashed #d9d9d9;
    border-radius: 20px;
    padding: 50px 30px;
    text-align: center;
    cursor: pointer;
    background: #fafafa;
    margin-bottom: 25px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.upload-section:hover:not(.disabled) {
    border-color: #667eea;
    background: #f0f3ff;
}

.upload-section.dragover {
    border-color: #667eea;
    background: #f0f3ff;
    transform: scale(1.02);
}

.upload-section.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.upload-icon {
    font-size: 48px;
    margin-bottom: 15px;
}

.upload-text {
    font-size: 18px;
    color: #666;
    margin-bottom: 8px;
}

.upload-hint {
    font-size: 14px;
    color: #999;
}

#preview-img {
    max-width: 100%;
    max-height: 250px;
    border-radius: 16px;
    display: none;
    margin: 20px auto 0;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

/* Generate Button */
.btn-generate {
    width: 100%;
    background: linear-gradient(135deg, #07C160 0%, #05a350 100%);
    color: white;
    border: none;
    padding: 20px;
    border-radius: 16px;
    font-size: 20px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 30px;
}

.btn-generate:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(7, 193, 96, 0.3);
}

.btn-generate:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Result Card */
.result-card {
    margin-top: 30px;
    border-radius: 20px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.group-header {
    padding: 20px 25px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.group-title {
    font-weight: 700;
    font-size: 18px;
    color: #333;
}

.status-tag {
    font-size: 13px;
    padding: 6px 16px;
    border-radius: 20px;
    font-weight: 600;
}

.status-pending {
    background: #fff3cd;
    color: #856404;
}

.status-processing {
    background: #cce5ff;
    color: #004085;
}

.status-done {
    background: #d4edda;
    color: #155724;
}

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

/* Image Container */
.image-container {
    width: 100%;
    min-height: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 30px;
}

.image-container img {
    width: 100%;
    max-width: 100%;
    height: auto;
    border-radius: 16px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

/* Loader */
.loader-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.loader {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}

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

.progress-bar {
    width: 200px;
    height: 6px;
    background: #e0e0e0;
    border-radius: 3px;
    overflow: hidden;
}

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

.timer {
    font-size: 14px;
    color: #666;
    text-align: center;
}

/* Cropped Grid */
.cropped-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 15px;
    padding: 25px;
    background: #f8f9fa;
}

.sticker-item {
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    background: white;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    cursor: pointer;
}

.sticker-item:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.15);
}

.sticker-item img {
    width: 100%;
    height: auto;
    display: block;
}

.sticker-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 8px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.7), transparent);
    color: white;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sticker-item:hover .sticker-label {
    opacity: 1;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 15px;
    padding: 25px;
    background: #f8f9fa;
    flex-wrap: wrap;
    justify-content: center;
}

.btn-action {
    padding: 14px 28px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
    background: white;
    color: #667eea;
    border: 2px solid #667eea;
}

.btn-secondary:hover {
    background: #f0f3ff;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #333;
    color: white;
    padding: 16px 32px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 500;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.success {
    background: #07C160;
}

.toast.error {
    background: #ff4d4f;
}

/* Responsive Design */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .app-container {
        padding: 25px 20px;
        border-radius: 20px;
    }

    h2 {
        font-size: 22px;
    }

    .code-input-wrapper {
        flex-direction: column;
    }

    .btn-verify {
        width: 100%;
    }

    .upload-section {
        padding: 35px 20px;
    }

    .upload-icon {
        font-size: 36px;
    }

    .upload-text {
        font-size: 16px;
    }

    .btn-generate {
        font-size: 18px;
        padding: 18px;
    }

    .cropped-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 10px;
        padding: 15px;
    }

    .action-buttons {
        flex-direction: column;
        padding: 20px;
    }

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

@media (max-width: 480px) {
    .cropped-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
        padding: 12px;
    }

    .sticker-label {
        font-size: 10px;
        padding: 6px;
    }
}

/* Touch feedback for mobile */
@media (hover: none) {
    .sticker-item:active {
        transform: scale(0.95);
    }

    .btn-generate:active:not(:disabled),
    .btn-verify:active:not(:disabled),
    .btn-action:active {
        transform: scale(0.95);
    }
}

/* Long press hint */
.long-press-hint {
    text-align: center;
    font-size: 13px;
    color: #999;
    padding: 10px;
    background: #f8f9fa;
}

/* History Section */
.history-section {
    margin-top: 30px;
    border-top: 1px solid #e0e0e0;
    padding-top: 20px;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.history-header h3 {
    margin: 0;
    font-size: 18px;
    color: #333;
}

.btn-text {
    background: none;
    border: none;
    color: #ff4d4f;
    font-size: 14px;
    cursor: pointer;
    padding: 5px 10px;
}

.btn-text:hover {
    background: #fff2f0;
    border-radius: 6px;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.history-item {
    display: flex;
    gap: 12px;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.history-item:hover {
    background: #f0f3ff;
}

.history-item img {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    object-fit: cover;
}

.history-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.history-time {
    font-size: 13px;
    color: #666;
}

.history-count {
    font-size: 12px;
    color: #999;
    margin-top: 4px;
}

.history-delete {
    background: none;
    border: none;
    color: #999;
    font-size: 18px;
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.history-delete:hover {
    color: #ff4d4f;
}

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

.modal-content {
    background: white;
    width: 100%;
    max-width: 400px;
    border-radius: 20px 20px 0 0;
    padding: 20px;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #999;
    cursor: pointer;
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.btn-modal {
    padding: 16px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    background: #f8f9fa;
    color: #333;
    transition: all 0.3s ease;
}

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

/* Mobile-specific save hint */
.save-hint-mobile {
    text-align: center;
    font-size: 14px;
    color: #667eea;
    padding: 15px;
    background: #f0f3ff;
    border-radius: 12px;
    margin: 10px 0;
}
