@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700;800&display=swap');

:root { 
    /* Unified SilverKey Brand Palette */
    --primary: #FF6F15;       /* Orange */
    --primary-hover: #e86513; 
    --accent: #3D4658;        /* Dark Gray */
    --bg-main: #e1e1df;       /* Neutral Page Background */
    --bg-card: #FFFFFF; 
    --text-main: #3D4658; 
    --border: #c3c6cb;        /* Gray 100 */
    --radius-md: 16px; 
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Cairo', sans-serif; -webkit-tap-highlight-color: transparent; }

body { 
    background: var(--bg-main); 
    color: var(--text-main); 
    display: flex; 
    flex-direction: column; 
    min-height: 100dvh; 
    padding-bottom: 54px; /* Space for the sk-bottom-nav */
    overflow-x: hidden;
    /* iOS smooth scrolling for the whole page */
    -webkit-overflow-scrolling: touch; 
}

.main-wrapper { 
    width: 100%; 
    padding: 40px 20px; 
    display: flex; 
    justify-content: center; 
    /* CRITICAL FIX: flex: 1 and min-height: 0 prevent Safari from trapping the scroll */
    flex: 1; 
    min-height: 0; 
}

.container { 
    width: 100%; 
    max-width: 900px; 
    background: var(--bg-card); 
    padding: 40px; 
    border-radius: var(--radius-md); 
    box-shadow: 0 10px 30px rgba(61,70,88,0.08); 
    position: relative; 
}

header h1 { font-size: clamp(28px, 5vw, 36px); margin-bottom: 8px; font-weight: 800; color: var(--primary); }
header p { color: #646b79; font-size: clamp(14px, 3vw, 16px); margin-bottom: 30px; font-weight: 500; }

.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 10px; }
.section-header h3 { font-size: 20px; font-weight: 700; color: var(--text-main); }
.mt-2 { margin-top: 32px; }

.upload-btn { background: #fff; border: 2px dashed var(--border); padding: 8px 16px; border-radius: 12px; cursor: pointer; color: var(--primary); font-weight: 700; font-size: 14px; transition: 0.2s; }
.upload-btn:active { transform: scale(0.95); background: rgba(255,111,21,0.05); }

.badge { background: var(--bg-main); padding: 6px 12px; border-radius: 20px; font-weight: 700; font-size: 14px; border: 1px solid var(--border); }

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

.card { border: 3px solid transparent; border-radius: 12px; padding: 8px; cursor: pointer; text-align: center; box-shadow: 0 2px 10px rgba(0,0,0,0.04); transition: 0.2s; background: #fff; }
.card img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; margin-bottom: 8px; pointer-events: none; }
.card p { font-size: 14px; font-weight: 600; }
.card.selected { border-color: var(--primary); background: rgba(255,111,21,0.05); transform: scale(0.98); }

.action-bar { margin-top: 40px; text-align: center; }

.primary-btn, .secondary-btn { border: none; padding: 16px 32px; font-size: 18px; font-weight: 800; border-radius: 30px; cursor: pointer; transition: 0.2s; width: 100%; max-width: 400px; }
.primary-btn { background: var(--primary); color: #fff; box-shadow: 0 4px 15px rgba(255,111,21,0.3); }
.primary-btn:disabled { background: var(--border); color: #fff; cursor: not-allowed; box-shadow: none; transform: none !important; }
.primary-btn:active:not(:disabled) { transform: scale(0.98); }
.secondary-btn { background: var(--accent); color: #fff; margin-top: 16px; }

.result-container { margin-top: 40px; padding-top: 30px; border-top: 1px solid var(--border); text-align: center; }
.loader { width: 40px; height: 40px; border: 4px solid var(--border); border-top: 4px solid var(--primary); border-radius: 50%; animation: spin 1s linear infinite; margin: 0 auto 10px; }
#result-image { width: 100%; max-width: 500px; border-radius: 16px; border: 4px solid white; box-shadow: 0 8px 24px rgba(61,70,88,0.12); margin-bottom: 20px; }

.hidden { display: none !important; }
@keyframes spin { 100% { transform: rotate(360deg); } }
@keyframes popIn { 0% { transform: scale(0.9); opacity: 0;} 100% { transform: scale(1); opacity: 1;} }
.shadow-pop { animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275); }

/* --- Mobile Responsiveness --- */
@media (max-width: 600px) {
    .main-wrapper { padding: 0; }
    .container { padding: 24px 20px 100px 20px; border-radius: 0; box-shadow: none; }

    /* Sticky Generate Button for Mobile */
    .action-bar { 
        position: fixed; 
        /* Sits right above the 54px sk-bottom-nav */
        bottom: 54px; 
        left: 0; width: 100%; 
        background: rgba(255, 255, 255, 0.95); backdrop-filter: blur(10px);
        padding: 16px 20px; 
        margin: 0; border-top: 1px solid var(--border); z-index: 100;
    }
    .primary-btn { max-width: 100%; }
    .upload-btn span { display: none; }
}
