/* ============================================================
   Worx Landroid Scheduler — Styles
   Thème nature/pelouse, mobile-first, grands éléments
   pour une utilisation facile sur smartphone.
   ============================================================ */

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --green-dark: #1b4332;
    --green: #2d6a4f;
    --green-light: #40916c;
    --green-pale: #b7e4c7;
    --green-bg: #d8f3dc;
    --white: #ffffff;
    --gray-50: #f8f9fa;
    --gray-100: #f1f3f5;
    --gray-200: #e9ecef;
    --gray-300: #dee2e6;
    --gray-500: #868e96;
    --gray-700: #495057;
    --gray-900: #212529;
    --red: #e03131;
    --red-bg: #fff5f5;
    --orange: #fd7e14;
    --orange-bg: #fff9db;
    --blue: #1971c2;
    --radius: 14px;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 20px rgba(0,0,0,0.12);
    --nav-height: 72px;
    --header-height: 56px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--gray-50);
    color: var(--gray-900);
    line-height: 1.5;
    min-height: 100dvh;
    overflow-x: hidden;
}

/* --- Screens --- */
.screen { display: none; }
.screen.active { display: flex; flex-direction: column; min-height: 100dvh; }

/* ============================================================
   LOGIN
   ============================================================ */
.login-container {
    max-width: 440px;
    margin: 0 auto;
    padding: 60px 24px 40px;
    text-align: center;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.login-logo { margin-bottom: 16px; }

.login-container h1 {
    font-size: 1.6rem;
    color: var(--green-dark);
    margin-bottom: 8px;
}

.login-subtitle {
    color: var(--gray-500);
    margin-bottom: 32px;
    font-size: 1rem;
}

.login-help {
    margin-top: 24px;
    font-size: 0.85rem;
    color: var(--gray-500);
    line-height: 1.4;
}

/* --- Forms --- */
.form-group {
    text-align: left;
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    font-size: 1rem;
    color: var(--gray-700);
}

input[type="email"],
input[type="password"],
input[type="number"],
input[type="time"],
select,
.input-field {
    width: 100%;
    padding: 14px 16px;
    font-size: 1.05rem;
    border: 2px solid var(--gray-300);
    border-radius: 10px;
    background: var(--white);
    color: var(--gray-900);
    transition: border-color 0.2s;
    -webkit-appearance: none;
}

input:focus, select:focus, .input-field:focus {
    outline: none;
    border-color: var(--green);
}

.error-message {
    background: var(--red-bg);
    color: var(--red);
    padding: 12px 16px;
    border-radius: 10px;
    margin-top: 16px;
    font-size: 0.95rem;
    text-align: left;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    font-size: 1.05rem;
    font-weight: 600;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary {
    background: var(--green);
    color: var(--white);
    width: 100%;
}
.btn-primary:hover:not(:disabled) { background: var(--green-dark); }

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-700);
    width: 100%;
}

.btn-large {
    padding: 16px 24px;
    font-size: 1.15rem;
}

.btn-small {
    padding: 10px 16px;
    font-size: 0.95rem;
    width: auto;
}

.btn-icon {
    background: none;
    border: none;
    color: var(--gray-500);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
}
.btn-icon:hover { background: var(--gray-100); }

/* ============================================================
   HEADER
   ============================================================ */
.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: var(--green);
    color: var(--white);
    height: var(--header-height);
}

.header-left {
    font-weight: 700;
    font-size: 1.1rem;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.dot-online { background: #51cf66; box-shadow: 0 0 6px #51cf66; }
.dot-offline { background: var(--gray-500); }
.dot-error { background: var(--red); box-shadow: 0 0 6px var(--red); }

/* ============================================================
   BOTTOM NAV
   ============================================================ */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    background: var(--white);
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding-bottom: env(safe-area-inset-bottom, 0);
    z-index: 100;
}

.nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    background: none;
    border: none;
    color: var(--gray-500);
    font-size: 0.72rem;
    font-weight: 500;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 10px;
    transition: color 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.nav-btn.active {
    color: var(--green);
}

.nav-btn svg {
    stroke: currentColor;
}

/* ============================================================
   TAB CONTENT
   ============================================================ */
.tab-content {
    flex: 1;
    padding: 20px 16px;
    padding-bottom: calc(var(--nav-height) + 20px);
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.section-title {
    font-size: 1.3rem;
    color: var(--green-dark);
    margin-bottom: 16px;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 16px 18px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
}

.card-status {
    display: flex;
    align-items: center;
    gap: 14px;
}

.card-icon {
    font-size: 2rem;
    flex-shrink: 0;
}

.card-status .card-icon { font-size: 2.5rem; }

.card:not(.card-status):not(.card-error) {
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

.card-body { flex: 1; min-width: 0; }

.card-label {
    font-size: 0.85rem;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    margin-bottom: 2px;
}

.card-value {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--gray-900);
}

.card-detail {
    font-size: 0.85rem;
    color: var(--gray-500);
    margin-top: 4px;
}

.card-error {
    background: var(--red-bg);
    border-left: 4px solid var(--red);
    display: flex;
    align-items: center;
    gap: 14px;
}
.card-error .card-value { color: var(--red); }

/* Status card colors */
.card-status.status-mowing { border-left: 4px solid var(--green); }
.card-status.status-home { border-left: 4px solid var(--blue); }
.card-status.status-error { border-left: 4px solid var(--red); }
.card-status.status-charging { border-left: 4px solid var(--orange); }

/* --- Progress bar --- */
.progress-bar {
    height: 10px;
    background: var(--gray-200);
    border-radius: 5px;
    margin-top: 8px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--green);
    border-radius: 5px;
    transition: width 0.5s ease;
}

.progress-fill.low { background: var(--red); }
.progress-fill.medium { background: var(--orange); }

/* ============================================================
   TOGGLES
   ============================================================ */
.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.toggle-label {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--gray-900);
}

.toggle {
    position: relative;
    width: 56px;
    height: 30px;
    flex-shrink: 0;
}

.toggle input { display: none; }

.toggle-slider {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--gray-300);
    border-radius: 30px;
    cursor: pointer;
    transition: background 0.3s;
}

.toggle-slider::before {
    content: "";
    position: absolute;
    width: 24px;
    height: 24px;
    left: 3px;
    bottom: 3px;
    background: var(--white);
    border-radius: 50%;
    transition: transform 0.3s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle input:checked + .toggle-slider {
    background: var(--green);
}

.toggle input:checked + .toggle-slider::before {
    transform: translateX(26px);
}

/* ============================================================
   SLIDERS
   ============================================================ */
.slider-container {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
}

.slider-label {
    font-size: 0.8rem;
    color: var(--gray-500);
    flex-shrink: 0;
    min-width: 40px;
    text-align: center;
}

input[type="range"] {
    flex: 1;
    height: 6px;
    -webkit-appearance: none;
    background: var(--gray-200);
    border-radius: 3px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--green);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.slider-value {
    text-align: center;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--green);
    margin-top: 4px;
}

/* ============================================================
   INPUT ROW
   ============================================================ */
.input-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
}

.input-row .input-field {
    width: 120px;
    flex-shrink: 0;
    text-align: center;
}

.input-unit {
    font-size: 0.95rem;
    color: var(--gray-500);
}

/* ============================================================
   HELP TEXT
   ============================================================ */
.help-text {
    font-size: 0.85rem;
    color: var(--gray-500);
    line-height: 1.4;
    margin-top: 4px;
}

.loading-text {
    text-align: center;
    color: var(--gray-500);
    padding: 20px;
}

/* ============================================================
   COMMANDS GRID
   ============================================================ */
.command-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.btn-command {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px 12px;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--white);
    box-shadow: var(--shadow);
    -webkit-tap-highlight-color: transparent;
    min-height: 110px;
}

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

.cmd-icon { font-size: 2rem; margin-bottom: 6px; }
.cmd-label { font-size: 1.05rem; font-weight: 700; color: var(--gray-900); }
.cmd-desc { font-size: 0.8rem; color: var(--gray-500); margin-top: 2px; }

.btn-start { border-bottom: 4px solid var(--green); }
.btn-start:active { background: var(--green-bg); }
.btn-pause { border-bottom: 4px solid var(--orange); }
.btn-pause:active { background: var(--orange-bg); }
.btn-home { border-bottom: 4px solid var(--blue); }
.btn-home:active { background: #e7f5ff; }
.btn-safehome { border-bottom: 4px solid #845ef7; }
.btn-safehome:active { background: #f3f0ff; }
.btn-edge { border-bottom: 4px solid #20c997; }
.btn-edge:active { background: #e6fcf5; }
.btn-restart { border-bottom: 4px solid var(--gray-500); }
.btn-restart:active { background: var(--gray-100); }

/* ============================================================
   ZONE BUTTONS
   ============================================================ */
.zone-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 10px;
}

.btn-zone {
    padding: 14px;
    font-size: 1rem;
    font-weight: 600;
    border: 2px solid var(--gray-300);
    border-radius: 10px;
    background: var(--white);
    color: var(--gray-700);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-zone:active { transform: scale(0.95); }
.btn-zone.active {
    border-color: var(--green);
    background: var(--green-bg);
    color: var(--green-dark);
}

/* ============================================================
   WEEKLY SCHEDULE — Day cards with Morning/Afternoon slots
   ============================================================ */
.day-card {
    background: var(--white);
    border-radius: var(--radius);
    margin-bottom: 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.day-card-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--white);
    background: var(--green);
    padding: 10px 16px;
}

.day-slot {
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-200);
}

.day-slot:last-child { border-bottom: none; }

.slot-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.slot-label {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-700);
}

.slot-config {
    margin-top: 12px;
}

.slot-row {
    display: flex;
    gap: 12px;
    margin-bottom: 10px;
}

.slot-row:last-child { margin-bottom: 0; }

.slot-field {
    flex: 1;
    min-width: 0;
}

.slot-field label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 4px;
}

.slot-field .input-field {
    padding: 10px 12px;
    font-size: 1rem;
}

.slot-field-toggle {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    padding-bottom: 4px;
}

.slot-duration-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
}

.slot-duration-wrap .input-field {
    width: 80px;
    text-align: center;
}

.toggle-small {
    width: 46px;
    height: 26px;
}

.toggle-small .toggle-slider::before {
    width: 20px;
    height: 20px;
}

.toggle-small input:checked + .toggle-slider::before {
    transform: translateX(20px);
}

/* ============================================================
   MODAL
   ============================================================ */
.modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.4);
}

.modal-content {
    position: relative;
    background: var(--white);
    border-radius: 20px 20px 0 0;
    padding: 28px 24px;
    width: 100%;
    max-width: 500px;
    max-height: 85vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

.modal-confirm {
    border-radius: 16px;
    margin: 16px;
    max-width: 400px;
    animation: fadeIn 0.2s ease;
}

.modal-confirm p {
    margin: 12px 0 20px;
    color: var(--gray-700);
    font-size: 1rem;
    line-height: 1.5;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.modal-content h3 {
    font-size: 1.2rem;
    color: var(--green-dark);
    margin-bottom: 20px;
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.modal-actions .btn {
    flex: 1;
}

/* ============================================================
   TOAST
   ============================================================ */
.toast {
    position: fixed;
    bottom: calc(var(--nav-height) + 16px);
    left: 50%;
    transform: translateX(-50%);
    padding: 14px 24px;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    z-index: 300;
    animation: toastIn 0.3s ease;
    max-width: calc(100% - 32px);
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.toast-success { background: var(--green); color: var(--white); }
.toast-error { background: var(--red); color: var(--white); }
.toast-info { background: var(--blue); color: var(--white); }

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

/* ============================================================
   LOADING SPINNER
   ============================================================ */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

/* ============================================================
   RESPONSIVE — Tablet/Desktop
   ============================================================ */
@media (min-width: 768px) {
    .tab-content {
        max-width: 640px;
        padding: 28px 24px;
        padding-bottom: calc(var(--nav-height) + 28px);
    }

    .command-grid {
        grid-template-columns: 1fr 1fr 1fr;
    }

    .modal-content {
        border-radius: 20px;
        margin-bottom: 40px;
    }
}
