/* ===============================
   VisiCanEU Master Dark Theme
   =============================== */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0; 
    padding: 40px 20px; 
    background-color: #0f172a; /* Deep slate blue */
    color: #e2e8f0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
}

/* Clever vertical centering for short pages, normal scroll for long pages */
.container {
    width: 100%;
    max-width: 800px;
    margin: auto; 
}
.container-sm { max-width: 600px; }
.text-center { text-align: center; }

/* ===============================
   Cards & Typography
   =============================== */
.card { 
    background-color: #1e293b; 
    border-radius: 24px; 
    padding: 40px 32px; 
    margin-bottom: 24px; 
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

h1 { font-size: 36px; font-weight: 800; color: #f8fafc; margin: 0 0 16px 0; letter-spacing: -0.02em; }
h2 { font-size: 22px; font-weight: 700; color: #f8fafc; margin: 0 0 16px 0; }
p { color: #94a3b8; line-height: 1.6; margin: 0 0 24px 0; font-size: 16px; }

.status-text { font-size: 14px; color: #94a3b8; margin-top: 12px; margin-bottom: 0; }

/* ===============================
   Forms & Inputs
   =============================== */
.form-group { margin-bottom: 24px; }
label { display: block; margin-bottom: 8px; color: #cbd5e1; font-size: 15px; font-weight: 600; }

select, input[type="file"], input[type="text"] {
    width: 100%; 
    background-color: #0f172a; 
    color: #e2e8f0; 
    border: 2px solid #334155;
    padding: 16px 20px; 
    border-radius: 16px; 
    font-size: 16px; 
    font-family: inherit; 
    outline: none;
    transition: border-color 0.2s;
    cursor: pointer;
}
select:focus, input:focus { border-color: #f97316; }

/* ===============================
   Buttons (Scaled Up)
   =============================== */
.btn-group { display: flex; gap: 16px; margin-top: 24px; flex-wrap: wrap; justify-content: center; }
.btn-stack { display: flex; flex-direction: column; gap: 16px; }

.btn {
    background-color: #f97316; /* VisiCan Orange */
    color: #ffffff; 
    border: none; 
    padding: 18px 32px; 
    font-size: 18px; 
    font-weight: 700; 
    border-radius: 9999px; /* Pill shape */
    cursor: pointer; 
    text-decoration: none; 
    display: inline-block;
    transition: all 0.2s;
    box-shadow: 0 4px 14px 0 rgba(249, 115, 22, 0.3);
    text-align: center;
    width: auto;
}
.btn.w-100 { width: 100%; }

.btn:hover:not(:disabled) { 
    background-color: #ea580c; 
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(249, 115, 22, 0.4);
}
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }

.btn.secondary { 
    background-color: transparent; 
    border: 2px solid #475569; 
    color: #e2e8f0; 
    box-shadow: none; 
}
.btn.secondary:hover:not(:disabled) { border-color: #94a3b8; color: #fff; }

.btn.sm { padding: 12px 20px; font-size: 14px; }
/* ===============================
   Galleries & Cropper Overrides
   =============================== */
.gallery-scroll { 
    display: flex; gap: 16px; overflow-x: auto; padding: 12px 0; 
    min-height: 140px; border: 2px dashed #334155; border-radius: 16px; margin-bottom: 24px; 
}
.sample-thumb { 
    flex: 0 0 116px; height: 116px; border-radius: 12px; border: 3px solid #334155; 
    cursor: pointer; background-size: cover; background-position: center; transition: all 0.2s; 
}
.sample-thumb:hover { border-color: #f97316; transform: scale(1.05); }

/* THE FIX: The hard-walled frame that stops infinite expansion */
.cropper-frame {
    width: 100%;
    height: 50vh;          /* Use 50% of screen height */
    max-height: 400px;     /* Never grow taller than 400px */
    min-height: 250px;     /* Never shrink smaller than 250px */
    background-color: #000;
    border-radius: 12px;
    overflow: hidden;
}

.cropper-frame img {
    display: block;
    max-width: 100%;
}

/* Let Cropper fill the frame naturally without fighting CSS */
.cropper-bg { background-image: none !important; background-color: #000 !important; }
.cropper-modal { background-color: rgba(0, 0, 0, 0.8) !important; }
.cropper-view-box { outline: 3px solid #f97316; }
.cropper-line, .cropper-point { display: none !important; }

/* ===============================
   Terminal & Hardware UI
   =============================== */
.terminal {
    background-color: #0b1120; padding: 24px; border-radius: 16px; 
    font-family: monospace; font-size: 14px; line-height: 1.6; 
    overflow-x: auto; white-space: pre-wrap; color: #d6e0ea;
}
.progress { width: 100%; height: 14px; background: rgba(255, 255, 255, 0.08); border-radius: 999px; overflow: hidden; margin-top: 24px; }
.progress__bar { height: 100%; width: 0%; background: #f97316; border-radius: 999px; transition: width 0.3s ease; }
.progress__bar--busy { position: relative; overflow: hidden; }
.progress__bar--busy::after { 
    content: ""; position: absolute; inset: 0; 
    background: linear-gradient(120deg, rgba(255,255,255,0.05) 25%, rgba(255,255,255,0.35) 50%, rgba(255,255,255,0.05) 75%); 
    animation: progress-stripes 1.2s linear infinite; 
}
@keyframes progress-stripes { 0% { transform: translateX(-60%); } 100% { transform: translateX(60%); } }

/* ===============================
   Footer Badge
   =============================== */
.footer-badge { margin-top: 40px; text-align: center; }
.badge {
    background-color: rgba(249, 115, 22, 0.1); border: 2px solid rgba(249, 115, 22, 0.2); 
    color: #f97316; padding: 12px 28px; border-radius: 9999px; font-size: 13px; font-weight: 700; 
    letter-spacing: 0.05em; text-decoration: none; display: inline-block; text-transform: uppercase; transition: background 0.2s;
}
.badge:hover { background-color: rgba(249, 115, 22, 0.15); }

/* Mobile Adjustments */
@media (max-width: 600px) {
    .card { padding: 32px 24px; }
    h1 { font-size: 32px; }
}

/* ===============================
   VisiCan Custom Grid Settings Layouts
   =============================== */
.visican-grid-container {
    margin-top: 16px;
    background: #0f172a;
    padding: 16px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.grid-main-32 {
    display: grid; 
    grid-template-columns: repeat(3, 1fr); 
    gap: 12px;
}
.grid-main-32 .empty-cell { visibility: hidden; }

.grid-main-24 {
    display: grid; 
    grid-template-columns: repeat(2, 1fr); 
    grid-template-rows: repeat(4, 1fr); 
    gap: 12px;
}

.grid-dial-32 {
    display: grid; 
    grid-template-columns: 2fr 1fr; 
    grid-template-rows: repeat(3, 1fr); 
    gap: 12px;
}
.grid-dial-32 .merged-cell {
    grid-row: span 3; 
    display: flex; 
    align-items: center; 
    justify-content: center;
    background: rgba(255, 255, 255, 0.02); 
    border-radius: 12px; 
    padding: 12px;
}

.grid-dial-24 {
    display: grid; 
    grid-template-columns: repeat(3, 1fr); 
    grid-template-rows: 2fr 1fr; 
    gap: 12px;
}
.grid-dial-24 .merged-cell {
    grid-column: span 3; 
    display: flex; 
    align-items: center; 
    justify-content: center;
    background: rgba(255, 255, 255, 0.02); 
    border-radius: 12px; 
    padding: 12px;
}

.grid-cell { display: flex; align-items: center; justify-content: center; width: 100%; }

.setting-select {
    width: 100%; 
    padding: 12px; 
    background-color: #334155; 
    color: #e2e8f0;
    border: 1px solid #475569; 
    border-radius: 8px; 
    font-size: 14px; 
    font-weight: 600;
    text-align: center;
    text-align-last: center; 
    cursor: pointer; 
    outline: none; 
    transition: border-color 0.2s, background-color 0.2s;
}
.setting-select:focus, .setting-select:hover { 
    border-color: #f97316; 
    background-color: #475569;
}