/* =============================================================
   KloPi Banner Webapp — Mobile-first dark theme
   Designed for touch interaction on smartphones
   ============================================================= */

/* Reset and base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    background-color: #0d1117;
    color: #e6edf3;
    min-height: 100vh;
}

/* Main container — centered, max width for readability on larger screens */
.app {
    max-width: 500px;
    margin: 0 auto;
    padding: 20px 16px 40px;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 24px;
}

header h1 {
    font-size: 24px;
    color: #58a6ff;
}

/* Section headings */
section {
    margin-bottom: 24px;
}

section h2 {
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #8b949e;
    margin-bottom: 12px;
}

/* =============================================================
   Layout selection grid — 2 columns of touch-friendly cards
   ============================================================= */

.layout-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.layout-card {
    background: #161b22;
    border: 2px solid #30363d;
    border-radius: 12px;
    padding: 14px 10px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    transition: border-color 0.2s, background-color 0.2s;
    /* Remove default button styling */
    color: #e6edf3;
    font-family: inherit;
    font-size: inherit;
    -webkit-tap-highlight-color: transparent;
}

.layout-card:hover {
    background: #1c2128;
}

/* Active/selected layout card — highlighted with blue border */
.layout-card.active {
    border-color: #58a6ff;
    background: #1c2a3a;
}

.layout-icon {
    font-size: 20px;
    height: 28px;
    display: flex;
    align-items: center;
}

.layout-name {
    font-size: 14px;
    font-weight: 600;
}

.layout-desc {
    font-size: 11px;
    color: #8b949e;
}

/* =============================================================
   Color pickers — side by side
   ============================================================= */

.color-row {
    display: flex;
    gap: 16px;
}

.color-picker {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.color-picker label {
    font-size: 13px;
    color: #8b949e;
}

/* Make the color input large and touch-friendly */
.color-picker input[type="color"] {
    width: 100%;
    height: 50px;
    border: 2px solid #30363d;
    border-radius: 10px;
    cursor: pointer;
    background: none;
    padding: 2px;
}

/* =============================================================
   Text input fields
   ============================================================= */

#text-fields {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#text-fields input[type="text"] {
    width: 100%;
    padding: 14px 16px;
    font-size: 16px; /* 16px prevents iOS auto-zoom on focus */
    background: #161b22;
    border: 2px solid #30363d;
    border-radius: 10px;
    color: #e6edf3;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

#text-fields input[type="text"]:focus {
    border-color: #58a6ff;
}

#text-fields input[type="text"]::placeholder {
    color: #484f58;
}

/* =============================================================
   Action buttons — row with apply (green) and delete (red)
   ============================================================= */

.button-row {
    display: flex;
    gap: 10px;
    margin-top: 8px;
}

.btn-apply {
    flex: 1;
    padding: 16px;
    font-size: 18px;
    font-weight: 600;
    color: #ffffff;
    background: #238636;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: background-color 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.btn-apply:hover {
    background: #2ea043;
}

.btn-apply:active {
    background: #1a7f37;
}

/* Disabled state while request is in flight */
.btn-apply:disabled {
    background: #21262d;
    color: #484f58;
    cursor: not-allowed;
}

.btn-delete {
    padding: 16px 20px;
    font-size: 14px;
    font-weight: 600;
    color: #f85149;
    background: #21262d;
    border: 1px solid #da3633;
    border-radius: 12px;
    cursor: pointer;
    transition: background-color 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.btn-delete:hover {
    background: #2d1215;
}

.btn-delete:active {
    background: #3d1519;
}

.btn-delete:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* =============================================================
   Status message — green for success, red for errors
   ============================================================= */

.status {
    text-align: center;
    padding: 12px;
    margin-top: 12px;
    border-radius: 8px;
    font-size: 14px;
    display: none; /* Hidden by default, shown via JS */
}

.status.success {
    display: block;
    background: #0d2818;
    color: #3fb950;
    border: 1px solid #238636;
}

.status.error {
    display: block;
    background: #2d1215;
    color: #f85149;
    border: 1px solid #da3633;
}

/* =============================================================
   Light sensor section
   ============================================================= */

.sensor-section {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #21262d;
}

.sensor-row {
    margin-bottom: 12px;
}

/* Toggle switch — a CSS-only on/off slider */
.toggle-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    user-select: none;
}

.toggle-input {
    display: none; /* Hide the native checkbox */
}

.toggle-slider {
    position: relative;
    width: 48px;
    height: 26px;
    background: #30363d;
    border-radius: 13px;
    transition: background 0.2s;
    flex-shrink: 0;
}

.toggle-slider::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    background: #8b949e;
    border-radius: 50%;
    transition: transform 0.2s, background 0.2s;
}

/* When the hidden checkbox is checked, style the slider as "on" */
.toggle-input:checked + .toggle-slider {
    background: #238636;
}

.toggle-input:checked + .toggle-slider::after {
    transform: translateX(22px);
    background: #ffffff;
}

.toggle-text {
    font-size: 16px;
    color: #e6edf3;
}

/* Range slider for lux threshold — 80% width for easy touch control */
.range-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    width: 80vw;
    max-width: 100%;
}

.range-row input[type="range"] {
    flex: 1;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: #30363d;
    border-radius: 3px;
    outline: none;
}

.range-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #58a6ff;
    cursor: pointer;
}

#threshold-value {
    font-weight: bold;
    min-width: 32px;
    text-align: right;
    color: #58a6ff;
}

.unit {
    color: #8b949e;
    font-size: 14px;
}

/* Sensor status display (current lux + display state) */
.sensor-status {
    font-size: 14px;
    color: #8b949e;
    min-height: 20px;
}

.sensor-lux {
    color: #e6edf3;
    font-weight: bold;
}

.sensor-on {
    color: #238636;
    font-weight: bold;
}

.sensor-off {
    color: #f85149;
    font-weight: bold;
}

/* =============================================================
   Link to page rotation management
   ============================================================= */

.pages-link {
    text-align: center;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid #21262d;
}

.pages-link a {
    color: #58a6ff;
    text-decoration: none;
    font-size: 14px;
}

.pages-link a:hover {
    text-decoration: underline;
}
