/* Form Elements */
.filters-bar {
    background: var(--bg-card);
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-lg);
    display: flex;
    gap: var(--spacing-md);
    align-items: center;
    box-shadow: var(--shadow-sm);
    flex-wrap: wrap;
}

.form-group {
    display: flex;
    flex-direction: column;
    min-width: 200px;
}

@media (max-width: 768px) {
    .filters-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .form-group {
        min-width: unset;
    }
}

@media (max-width: 480px) {
    .filters-bar {
        padding: var(--spacing-sm);
    }
}

.form-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    display: block;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.form-select,
.form-input {
    padding: 0.6rem 0.75rem;
    min-height: 40px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text-main);
    background-color: white;
    transition: all 0.2s;
}

@media (max-width: 768px) {

    .form-select,
    .form-input {
        min-height: 48px;
        /* Safe thumb target */
        padding: 0.75rem;
        /* ~12px padding */
        font-size: 16px !important;
        /* Critical to prevent iOS Zoom */
    }
}

.form-select {
    cursor: pointer;
}

.form-input::placeholder {
    color: #cbd5e1;
}

.form-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

textarea.form-input {
    resize: vertical;
    min-height: 80px;
    font-family: inherit;
}

.btn-primary {
    background-color: var(--color-primary);
    color: white;
    padding: 0.6rem 1.25rem;
    min-height: 40px;
    border: none;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.95rem;
    display: inline-flex;
    align-items: center;
}

@media (max-width: 480px) {
    .btn-primary {
        min-height: 44px;
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
        width: 100%;
        justify-content: center;
    }
}

.btn-primary:hover {
    background-color: #2563eb;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.2);
}

.btn-primary:active {
    transform: translateY(1px);
}

.btn-primary:disabled {
    background-color: #cbd5e1;
    cursor: not-allowed;
    opacity: 0.6;
}

.btn-secondary {
    background-color: var(--bg-card);
    color: var(--text-main);
    padding: 0.6rem 1.25rem;
    min-height: 40px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.95rem;
    display: inline-flex;
    align-items: center;
}

@media (max-width: 480px) {
    .btn-secondary {
        min-height: 44px;
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
        width: 100%;
        justify-content: center;
    }
}

.btn-secondary:hover {
    background-color: var(--bg-hover);
    border-color: var(--text-muted);
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    min-height: 36px;
    font-size: 0.85rem;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
}

@media (max-width: 480px) {
    .btn-sm {
        min-height: 40px;
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }
}

/* Input Error States */
.form-input.is-error,
.form-select.is-error {
    border-color: var(--color-danger);
    background-color: #fef2f2;
}

.form-input.is-error:focus,
.form-select.is-error:focus {
    outline: none;
    border-color: var(--color-danger);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.form-error-message {
    font-size: 0.8rem;
    color: var(--color-danger);
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Form group spacing in modals */
.modal-form .form-group {
    min-width: unset;
}

.modal-form .form-input,
.modal-form .form-select {
    width: 100%;
}

/* -----------------------------------------------
   Toggle Switch (used in Recurring Routines table)
----------------------------------------------- */
.switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
    flex-shrink: 0;
}

/* Hide the native checkbox — the span below is the visual */
.switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.slider {
    position: absolute;
    inset: 0;
    background-color: #cbd5e1; /* Slate 300 — paused state */
    border-radius: 999px;
    cursor: pointer;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

/* Knob */
.slider::before {
    content: '';
    position: absolute;
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease;
}

/* Active state */
.switch input:checked + .slider {
    background-color: #16a34a; /* Green 600 */
}

/* Move the knob to the right when checked */
.switch input:checked + .slider::before {
    transform: translateX(22px);
}

/* WCAG focus ring — visible on keyboard navigation */
.switch input:focus-visible + .slider {
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.35);
}