/* =================================================================
   1. GLOBAL & MOBILE-FIRST RESET 📱
   ================================================================= */
:root {
    --primary-color: #1a73e8; /* Blue */
    --success-color: #0d9488; /* Teal/Success */
    --secondary-color: #4b5563; /* Gray */
    --light-bg: #f7f7f7;
    --card-bg: #ffffff;
    --border-color: #e5e7eb;
    --safe-area-top: env(safe-area-inset-top);
    --safe-area-bottom: env(safe-area-inset-bottom);
    --vh: 1vh; /* Set by inline JS */
}

html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--light-bg);
    color: #1f2937;
    /* Prevent vertical bounce if not necessary */
    min-height: 100%;
}

/* Ensure body takes up the full screen height (using the JS calculated --vh) */
.ios-safe {
    min-height: calc(var(--vh, 1vh) * 100);
}

/* Safe area padding (for notch/home bar) */
.safe-top { height: var(--safe-area-top); }
.safe-bottom { height: var(--safe-area-bottom); }

/* When the keyboard is open, ensure space at the bottom */
.kb-open .page {
    /* If the page height is constrained, this helps content scroll above the keyboard */
    padding-bottom: 20px; 
}


/* =================================================================
   2. TYPOGRAPHY & HEADER
   ================================================================= */
.title {
    font-size: 1.8rem;
    color: var(--primary-color);
    text-align: center;
    margin: 0 0 5px 0;
}
.sub {
    font-size: 0.9rem;
    color: var(--secondary-color);
    text-align: center;
    margin-bottom: 20px;
}
label {
    display: block;
    font-weight: 600;
    margin-bottom: 4px;
    font-size: 0.9rem;
    color: #374151;
}
small {
    display: block;
    font-size: 0.75rem;
    color: #6b7280;
    margin-top: 2px;
}
.hint {
    opacity: 0.8;
}

/* =================================================================
   3. CONTAINERS & CARDS
   ================================================================= */
.page {
    max-width: 600px;
    margin: 0 auto;
    padding: 0 16px;
    padding-bottom: calc(20px + var(--safe-area-bottom));
}
.page-head {
    padding-top: 15px;
}
.card {
    background: var(--card-bg);
    padding: 16px;
    border-radius: 12px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
    margin-bottom: 20px;
}
.card-lite {
    background: #fcfcfc;
    border: 1px solid var(--border-color);
    padding: 15px;
    border-radius: 8px;
    margin-top: 20px;
}

/* =================================================================
   4. FORM ELEMENTS & IOS ZOOM FIXES
   ================================================================= */
.row {
    margin-bottom: 16px;
}

/* The crucial iPhone fix: ensures font size is >= 16px to prevent zoom */
input[type="text"], 
input[type="color"], 
input[type="file"], 
input[type="range"],
select, 
textarea,
.no-zoom {
    font-size: 16px; /* KEY FIX: prevents iOS from zooming when focused */
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    width: 100%;
    box-sizing: border-box;
    -webkit-appearance: none;
    appearance: none;
    background-color: var(--card-bg);
    color: #1f2937;
    transition: border-color 0.2s;
}

input[type="text"]:focus,
select:focus {
    border-color: var(--primary-color);
    outline: none;
}

/* Style for color inputs */
input[type="color"] {
    padding: 2px;
    height: 40px;
    width: 100%;
    cursor: pointer;
}

/* Style for range inputs (needs specific styling for visual consistency) */
input[type="range"] {
    height: 25px;
    padding: 0;
    border: none;
    background: transparent;
    cursor: grab;
}

/* Checkbox style */
input[type="checkbox"] {
    width: auto;
    height: 16px;
    margin-right: 8px;
    -webkit-appearance: checkbox;
    appearance: checkbox;
    vertical-align: middle;
}

/* =================================================================
   5. BUTTONS & ACTIONS
   ================================================================= */
.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 20px;
}
.actions button {
    flex-grow: 1;
    min-width: 120px;
}

button {
    font-size: 1rem;
    padding: 12px 15px;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.2s, opacity 0.2s;
    line-height: 1;
}
.btn-small {
    font-size: 0.85rem;
    padding: 8px 10px;
    font-weight: 500;
    border-radius: 6px;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
    border: 1px solid var(--primary-color);
}
.btn-success {
    background-color: var(--success-color);
    color: white;
    border: 1px solid var(--success-color);
}
.btn-secondary {
    background-color: var(--card-bg);
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
}
.btn-muted {
    background-color: #f3f4f6;
    color: #4b5563;
    border: 1px solid #d1d5db;
}

button:hover {
    opacity: 0.9;
}


/* =================================================================
   6. GRID LAYOUTS (MOBILE-FIRST)
   ================================================================= */

/* Default is 1 column (already handled by .row and input 100% width) */
.grid-2, .grid-3 {
    display: grid;
    gap: 16px;
    grid-template-columns: 1fr; /* Default to single column on small screens */
}

@media (min-width: 400px) {
    /* Two columns for mid-size screens and above */
    .grid-2 {
        grid-template-columns: 1fr 1fr;
    }
}

@media (min-width: 550px) {
    /* Three columns for wider screens */
    .grid-3 {
        grid-template-columns: repeat(3, 1fr);
    }
}


/* =================================================================
   7. QR PREVIEW & LOGO OVERLAY
   ================================================================= */
.qr-wrap {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 15px;
    background: var(--card-bg);
    border-radius: 8px;
    position: relative; /* For logo positioning */
    min-height: 200px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.qr-wrap svg {
    display: block;
    max-width: 100%;
    height: auto;
}

.logoBox {
    width: 60px;
    height: 60px;
    line-height: 60px;
    text-align: center;
    background: #f9fafb;
    border: 1px dashed #d1d5db;
    border-radius: 8px;
    font-size: 20px;
}
.logoBox img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 6px;
}

/* Logo Overlay (runtime positioned by JS) */
.logoOverlay {
    position: absolute;
    /* Styles for the border are injected by JS based on contrast, 
       but this sets the base visual properties for the container */
    border-radius: 14px; 
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
}

/* =================================================================
   8. ADVANCED PANEL & EFFECTS
   ================================================================= */
.advanced {
    border-top: 1px solid var(--border-color);
    padding-top: 15px;
    margin-top: 15px;
}
.hidden {
    display: none !important;
}

/* Placeholder styles for QR_EFFECTS (add more specific effects in your app_2.css) */
.qr-wrap.glow {
    box-shadow: 0 0 15px 5px rgba(26, 115, 232, 0.5); /* Primary color glow */
}
.qr-wrap.drip {
    /* Requires advanced SVG filters or complex SVG generation; 
       for CSS only, this might be a subtle background texture change */
    background: repeating-linear-gradient(45deg, #f7f7f7, #f7f7f7 10px, #fcfcfc 10px, #fcfcfc 20px);
}
