:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --bg: #f3f4f6;
    --surface: #ffffff;
    --text: #1f2937;
    --text-light: #6b7280;
    --border: #e5e7eb;
    --radius: 0.5rem;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    padding-bottom: 70px;
    /* Space for bottom nav */
}

/* Environment Banner */
#env-banner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    z-index: 1000;
    position: relative;
}

.env-text {
    flex-grow: 1;
    text-align: center;
}

#env-banner .close-banner {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0 0.5rem;
    color: inherit;
    opacity: 0.5;
    transition: opacity 0.2s;
    line-height: 1;
}

#env-banner.localdev {
    background: #fef9c3;
    color: #854d0e;
}

#env-banner.remotedev {
    background: #dcfce7;
    color: #166534;
}

header {
    background: var(--surface);
    padding: 1rem;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

h1 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
}

/* Status Indicators */
.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.indicator-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-indicator.online .indicator-dot {
    background: #10b981;
}

.status-indicator.offline .indicator-dot {
    background: #ef4444;
}

main {
    max-width: 800px;
    margin: 1rem auto;
    padding: 0 1rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

h2 {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
}

/* Grid and Cards */
.grid-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-card {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-left: 5px solid #e5e7eb;
}

.form-card.stop-card {
    border-left-color: #84cc16;
}

.form-card:hover {
    border-color: var(--primary);
    transform: translateX(2px);
}

.stop-info h3 {
    margin: 0 0 0.25rem 0;
    font-size: 1rem;
}

.template-name {
    font-size: 0.75rem;
    color: var(--text-light);
    font-weight: 500;
    margin: 0;
}

.stop-info .description {
    margin: 0.25rem 0 0 0;
    color: var(--text-light);
    font-size: 0.875rem;
}

.stop-status {
    background: #f0fdf4;
    color: #166534;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Form Layout */
.form-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 1.5rem;
    padding: 1.5rem;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.form-group {
    grid-column: span 6;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group.half {
    grid-column: span 3;
}

.form-group.third {
    grid-column: span 2;
}

@media (max-width: 600px) {

    .form-group.half,
    .form-group.third {
        grid-column: span 6;
    }
}

.form-group.header {
    border-bottom: 2px solid var(--border);
    margin-top: 1rem;
    padding-bottom: 0.25rem;
}

.form-group label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
}

input,
textarea {
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    font-size: 1rem;
    width: 100%;
}

.checkbox-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    font-weight: 500;
}

.checkbox-container input {
    width: auto;
}

/* Signature */
.signature-pad-container {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #f9fafb;
    position: relative;
}

canvas {
    width: 100%;
    height: 200px;
    touch-action: none;
    cursor: crosshair;
}

.canvas-actions {
    padding: 0.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border-radius: 0.375rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: background 0.2s;
}

.btn.primary {
    background: var(--primary);
    color: white;
    width: 100%;
}

.btn.primary:hover {
    background: var(--primary-hover);
}

.btn.secondary {
    background: #e5e7eb;
    color: #374151;
}

.btn.link {
    background: none;
    color: var(--primary);
    padding: 0.5rem 0;
    margin-bottom: 0.5rem;
}

/* Bottom Nav */
.bottom-nav {
    position: fixed;
    bottom: 0;
    width: 100%;
    background: var(--surface);
    display: flex;
    justify-content: space-around;
    padding: 10px 0;
    box-shadow: 0 -1px 3px rgba(0, 0, 0, 0.1);
    z-index: 100;
}

.nav-item {
    text-decoration: none;
    color: var(--text-light);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
}

.nav-item.active {
    color: var(--primary);
}

.nav-item .icon {
    font-size: 1.25rem;
}

.badge {
    background: #ef4444;
    color: white;
    padding: 2px 6px;
    border-radius: 9999px;
    font-weight: 700;
    position: absolute;
    margin-left: 15px;
    margin-top: -5px;
}

.hidden {
    display: none !important;
}

.loader {
    text-align: center;
    padding: 2rem;
    color: var(--text-light);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 1rem;
    left: 0;
    right: 0;
    margin-left: auto;
    margin-right: auto;
    z-index: 1000;
    background-color: #333;
    /* Dark background */
    color: white;
    padding: 0.75rem 1.25rem;
    border-radius: 9999px;
    /* Pill shape */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 200px;
    max-width: 350px;
    opacity: 0;
    transform: translateY(20px);
    /* Initial state for animation */
    animation: slideInToast 0.3s forwards;
    font-size: 0.9rem;
    font-weight: 500;
    pointer-events: auto;
    /* Re-enable pointer events for the toast itself */
}

.toast.error {
    background-color: #dc2626;
    /* Red for error */
}

.toast.success {
    background-color: #16a34a;
    /* Green for success */
}

.toast-icon {
    font-size: 1.1rem;
    line-height: 1;
}

.toast-message {
    flex-grow: 1;
    text-align: center;
}

.toast-close-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 1rem;
    cursor: pointer;
    padding: 0;
    margin-left: 0.5rem;
}

.toast-close-btn:hover {
    color: white;
}

@keyframes slideInToast {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}