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

body {
    font-family: 'esamanru', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* ================================
   Container
   ================================ */
.container {
    max-width: 480px;
    margin: 0 auto;
    padding: 0;
    min-height: 100vh;
    background: #ffffff;
    position: relative;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.1);
}

/* ================================
   Header
   ================================ */
.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2rem 1.5rem;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.title {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    letter-spacing: -0.5px;
}

.subtitle {
    font-size: 0.95rem;
    font-weight: 300;
    opacity: 0.95;
}

/* ================================
   Main Content
   ================================ */
.main-content {
    padding: 1.5rem;
    padding-bottom: 100px;
}

/* ================================
   Upload Section
   ================================ */
.upload-section {
    margin-bottom: 1.5rem;
}

.file-input {
    display: none;
}

.upload-area {
    min-height: 280px;
    border: 2px dashed #e0e0e0;
    border-radius: 16px;
    background: #fafafa;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
}

.upload-area:hover {
    border-color: #667eea;
    background: #f5f5ff;
}

.upload-area:active {
    transform: scale(0.98);
}

.upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 280px;
    padding: 2rem;
}

.upload-icon {
    color: #9ca3af;
    margin-bottom: 1rem;
    width: 64px;
    height: 64px;
}

.upload-text {
    font-size: 1.125rem;
    font-weight: 600;
    color: #4a4a4a;
    margin-bottom: 0.5rem;
}

.upload-subtext {
    font-size: 0.875rem;
    color: #9ca3af;
}

/* ================================
   Image Preview
   ================================ */
.image-preview {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 280px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    border-radius: 14px;
    overflow: hidden;
}

.preview-image {
    max-width: 100%;
    max-height: 400px;
    height: auto;
    object-fit: contain;
    display: block;
    /* Ensure browser respects EXIF orientation */
    image-orientation: from-image;
}

.remove-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    color: #ef4444;
}

.remove-btn:hover {
    background: #ffffff;
    transform: scale(1.1);
}

.remove-btn:active {
    transform: scale(0.95);
}

/* ================================
   File Info
   ================================ */
.file-info {
    margin-top: 1rem;
    padding: 1rem;
    background: #f9fafb;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
}

.info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
}

.info-item:not(:last-child) {
    border-bottom: 1px solid #e5e7eb;
}

.info-label {
    font-size: 0.875rem;
    color: #6b7280;
    font-weight: 500;
}

.info-value {
    font-size: 0.875rem;
    color: #374151;
    font-weight: 600;
    text-align: right;
    word-break: break-all;
    max-width: 60%;
}

/* ================================
   Buttons
   ================================ */
.action-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
}

.btn:active {
    transform: scale(0.95);
}

.btn-secondary {
    background: #f3f4f6;
    color: #4b5563;
    border: 1px solid #e5e7eb;
}

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

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

.btn-primary:hover:not(:disabled) {
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: scale(0.95);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}

/* ================================
   Loading Overlay
   ================================ */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-text {
    color: white;
    margin-top: 1.5rem;
    font-size: 1.125rem;
    font-weight: 500;
}

/* ================================
   Messages
   ================================ */
.message {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 1rem 1.5rem;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    z-index: 10000;
    animation: slideDown 0.3s ease;
    max-width: calc(100% - 2rem);
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.success-message {
    background: #10b981;
    color: white;
}

.error-message {
    background: #ef4444;
    color: white;
}

/* ================================
   Responsive Design
   ================================ */
@media (max-width: 480px) {
    .container {
        max-width: 100%;
        box-shadow: none;
    }
    
    .header {
        padding: 1.5rem 1rem;
    }
    
    .title {
        font-size: 1.5rem;
    }
    
    .main-content {
        padding: 1rem;
    }
    
    .upload-area {
        min-height: 240px;
    }
    
    .upload-placeholder {
        min-height: 240px;
    }
    
    .upload-icon {
        width: 48px;
        height: 48px;
    }
}

@media (min-width: 768px) {
    .container {
        margin: 2rem auto;
        border-radius: 24px;
        overflow: hidden;
        min-height: calc(100vh - 4rem);
    }
    
    .header {
        border-radius: 24px 24px 0 0;
    }
}

/* ================================
   iOS Specific Styles
   ================================ */
@supports (-webkit-touch-callout: none) {
    .btn {
        -webkit-appearance: none;
    }
    
    input[type="file"] {
        -webkit-appearance: none;
    }
}

/* ================================
   QR Code Message Styles
   ================================ */
.qr-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1.5rem;
    min-height: 400px;
    text-align: center;
}

.qr-icon {
    margin-bottom: 2rem;
    color: #9ca3af;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.qr-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #374151;
    margin-bottom: 1rem;
    letter-spacing: -0.5px;
}

.qr-subtitle {
    font-size: 1rem;
    color: #6b7280;
    line-height: 1.5;
    max-width: 320px;
}

/* ================================
   Dark Mode Support (Optional)
   ================================ */
@media (prefers-color-scheme: dark) {
    body {
        background: linear-gradient(135deg, #4c1d95 0%, #5b21b6 100%);
    }
    
    .container {
        background: #1f2937;
        color: #f3f4f6;
    }
    
    .upload-area {
        background: #111827;
        border-color: #374151;
    }
    
    .upload-area:hover {
        background: #1f2937;
        border-color: #667eea;
    }
    
    .upload-text {
        color: #f3f4f6;
    }
    
    .file-info {
        background: #111827;
        border-color: #374151;
    }
    
    .info-item:not(:last-child) {
        border-color: #374151;
    }
    
    .info-label {
        color: #9ca3af;
    }
    
    .info-value {
        color: #e5e7eb;
    }
    
    .btn-secondary {
        background: #374151;
        color: #e5e7eb;
        border-color: #4b5563;
    }
    
    .btn-secondary:hover {
        background: #4b5563;
    }
    
    .qr-title {
        color: #f3f4f6;
    }
    
    .qr-subtitle {
        color: #d1d5db;
    }
    
    .qr-icon {
        color: #d1d5db;
    }
}