/* ============================================================================
   KIT MANAGER - FORM STYLES
   ============================================================================ */

/* --- Form Container --- */
.form-container {
    padding: 1rem;
    padding-bottom: calc(var(--nav-height, 64px) + env(safe-area-inset-bottom, 0px) + 1rem);
    max-width: 600px;
    margin: 0 auto;
}

/* --- Mode Toggle (Delivery/Collection) --- */
.mode-toggle {
    display: flex;
    background: #e5e7eb;
    border-radius: 12px;
    padding: 4px;
    margin-bottom: 1.5rem;
}

.mode-toggle-btn {
    flex: 1;
    padding: 0.875rem 1rem;
    border: none;
    background: transparent;
    font-size: 1rem;
    font-weight: 600;
    color: #6b7280;
    cursor: pointer;
    border-radius: 10px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.mode-toggle-btn img {
    width: 20px;
    height: 20px;
    opacity: 0.6;
}

.mode-toggle-btn.active {
    background: white;
    color: #1f2937;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.mode-toggle-btn.active img {
    opacity: 1;
}

/* Delivery mode active */
.mode-toggle-btn.active[data-mode="delivery"] {
    background: #10b981;
    color: white;
}

/* Collection mode active */
.mode-toggle-btn.active[data-mode="collection"] {
    background: #f59e0b;
    color: white;
}

/* --- Form Section --- */
.form-section {
    background: white;
    border-radius: 12px;
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.form-section-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
}

/* --- Form Group --- */
.form-group {
    margin-bottom: 1rem;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.5rem;
}

.form-label.required::after {
    content: ' *';
    color: #ef4444;
}

/* --- Text Input --- */
.form-input {
    width: 100%;
    padding: 0.875rem 1rem;
    font-size: 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    background: white;
    color: #1f2937;
    transition: all 0.2s;
    -webkit-appearance: none;
    appearance: none;
}

.form-input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-input::placeholder {
    color: #9ca3af;
}

.form-input:disabled {
    background: #f3f4f6;
    color: #9ca3af;
}

/* --- Textarea --- */
.form-textarea {
    width: 100%;
    padding: 0.875rem 1rem;
    font-size: 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    background: white;
    color: #1f2937;
    transition: all 0.2s;
    resize: vertical;
    min-height: 100px;
    font-family: inherit;
}

.form-textarea:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* --- Select Dropdown --- */
.form-select {
    width: 100%;
    padding: 0.875rem 2.5rem 0.875rem 1rem;
    font-size: 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    background: white url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%236b7280'%3E%3Cpath fill-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z' clip-rule='evenodd'/%3E%3C/svg%3E") no-repeat right 0.75rem center;
    background-size: 1.25rem;
    color: #1f2937;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

.form-select:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* --- Searchable Dropdown --- */
.searchable-dropdown {
    position: relative;
}

.searchable-dropdown .form-input {
    padding-right: 2.5rem;
}

.dropdown-arrow {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    pointer-events: none;
    opacity: 0.5;
}

.dropdown-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 2px solid #e5e7eb;
    border-top: none;
    border-radius: 0 0 8px 8px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 9999;
    display: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    -webkit-overflow-scrolling: touch;
}

.dropdown-list.show {
    display: block;
}

.dropdown-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: background 0.15s;
}

.dropdown-item:hover,
.dropdown-item.highlighted {
    background: #f3f4f6;
}

.dropdown-item.selected {
    background: #dbeafe;
    color: #1d4ed8;
    font-weight: 500;
}

/* --- Site Selection Buttons --- */
.site-buttons {
    display: flex;
    gap: 0.75rem;
}

.site-btn {
    flex: 1;
    padding: 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    background: white;
    font-size: 1rem;
    font-weight: 600;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.site-btn:hover {
    border-color: #2563eb;
    background: #f8fafc;
}

.site-btn.selected {
    border-color: #2563eb;
    background: #dbeafe;
    color: #1d4ed8;
}

/* --- GPS Button --- */
.gps-btn {
    padding: 0.75rem 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    background: white;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.gps-btn:hover {
    border-color: #2563eb;
    background: #f8fafc;
}

.gps-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* --- Recent Locations --- */
.recent-locations {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.recent-location-chip {
    padding: 0.375rem 0.75rem;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 20px;
    font-size: 0.813rem;
    color: #4b5563;
    cursor: pointer;
    transition: all 0.15s;
}

.recent-location-chip:hover {
    background: #dbeafe;
    border-color: #93c5fd;
    color: #1d4ed8;
}

/* --- Checkbox --- */
.form-checkbox-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0;
}

.form-checkbox {
    width: 22px;
    height: 22px;
    border: 2px solid #d1d5db;
    border-radius: 4px;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    background: white;
    transition: all 0.15s;
}

.form-checkbox:checked {
    background: #2563eb;
    border-color: #2563eb;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='white'%3E%3Cpath fill-rule='evenodd' d='M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z' clip-rule='evenodd'/%3E%3C/svg%3E");
    background-size: 14px;
    background-position: center;
    background-repeat: no-repeat;
}

.form-checkbox-label {
    font-size: 0.938rem;
    color: #374151;
    cursor: pointer;
}

/* --- Conditional Fields (shown when checkbox is checked) --- */
.conditional-fields {
    display: none;
    padding-top: 1rem;
    border-top: 1px solid #e5e7eb;
    margin-top: 0.5rem;
}

.conditional-fields.show {
    display: block;
}

/* --- Photo Upload --- */
.photo-upload-section {
    margin-top: 0.5rem;
}

.photo-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
}

.photo-item {
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    background: #f3f4f6;
}

.photo-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.photo-item .remove-photo {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    background: rgba(0, 0, 0, 0.6);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.add-photo-btn {
    aspect-ratio: 1;
    border: 2px dashed #d1d5db;
    border-radius: 8px;
    background: #f9fafb;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    transition: all 0.2s;
}

.add-photo-btn:hover {
    border-color: #2563eb;
    background: #eff6ff;
}

.add-photo-btn img {
    width: 28px;
    height: 28px;
    opacity: 0.5;
}

.add-photo-btn span {
    font-size: 0.75rem;
    color: #6b7280;
}

/* Hidden file input */
.photo-input {
    display: none;
}

/* --- Submit Button --- */
.submit-section {
    padding: 1rem;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    margin-top: 1rem;
}

.submit-btn {
    width: 100%;
    padding: 1rem;
    border: none;
    border-radius: 12px;
    font-size: 1.125rem;
    font-weight: 600;
    color: white;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.submit-btn.delivery {
    background: #10b981;
}

.submit-btn.delivery:hover:not(:disabled) {
    background: #059669;
}

.submit-btn.collection {
    background: #f59e0b;
}

.submit-btn.collection:hover:not(:disabled) {
    background: #d97706;
}

.submit-btn img {
    width: 20px;
    height: 20px;
    filter: brightness(0) invert(1);
}

/* --- Form Validation --- */
.form-input.error,
.form-select.error,
.form-textarea.error {
    border-color: #ef4444;
    background: #fef2f2;
}

.form-input.error:focus,
.form-select.error:focus,
.form-textarea.error:focus {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

/* Site buttons error state */
.site-buttons.error .site-btn {
    border-color: #ef4444;
    background: #fef2f2;
}

/* Searchable dropdown error state */
.searchable-dropdown.error .form-input {
    border-color: #ef4444;
    background: #fef2f2;
}

.searchable-dropdown.error .form-input:focus {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

/* Items entry form error state (when no items added) */
.item-entry-form.error {
    border: 2px solid #ef4444;
    border-radius: 8px;
    padding: 0.75rem;
    background: #fef2f2;
}

.form-error {
    color: #ef4444;
    font-size: 0.813rem;
    margin-top: 0.375rem;
}

/* --- Offline Indicator --- */
.offline-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: #fbbf24;
    color: #92400e;
    text-align: center;
    padding: 0.625rem;
    font-size: 0.875rem;
    font-weight: 500;
    z-index: 1001;
    display: none;
}

.offline-banner.show {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.offline-banner img {
    width: 16px;
    height: 16px;
}

/* When offline banner is showing, push content down */
body.offline .main-content {
    padding-top: 40px;
}

/* --- Success Message --- */
.success-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.success-overlay.show {
    opacity: 1;
    visibility: visible;
}

.success-content {
    background: white;
    border-radius: 16px;
    padding: 2rem;
    text-align: center;
    max-width: 320px;
    transform: scale(0.9);
    transition: transform 0.3s;
}

.success-overlay.show .success-content {
    transform: scale(1);
}

.success-icon {
    width: 64px;
    height: 64px;
    background: #10b981;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
}

.success-icon img {
    width: 32px;
    height: 32px;
    filter: brightness(0) invert(1);
}

.success-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 0.5rem;
}

.success-message {
    color: #6b7280;
    font-size: 0.938rem;
    margin-bottom: 1.5rem;
}

.success-btn {
    padding: 0.75rem 2rem;
    background: #2563eb;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
}

/* --- Add Item Button --- */
.add-item-btn {
    padding: 0.875rem 1.25rem;
    background: #2563eb;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.add-item-btn:hover {
    background: #1d4ed8;
}

.add-item-btn:active {
    transform: scale(0.98);
}

/* --- Items List --- */
.items-list {
    margin-top: 1rem;
}

.items-list:empty {
    display: none;
}

.items-list-header {
    font-size: 0.75rem;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #e5e7eb;
}

.item-row {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    background: #f9fafb;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    gap: 0.75rem;
}

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

.item-qty {
    flex: 0 0 40px;
    font-weight: 600;
    color: #1f2937;
    text-align: center;
    background: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.875rem;
}

.item-details {
    flex: 1;
    min-width: 0;
}

.item-description {
    font-size: 0.938rem;
    color: #1f2937;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.item-code {
    font-size: 0.75rem;
    color: #6b7280;
    margin-top: 0.125rem;
}

.item-remove {
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
    background: #fee2e2;
    border: none;
    border-radius: 6px;
    color: #dc2626;
    font-size: 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.item-remove:hover {
    background: #fecaca;
}

/* --- Responsive --- */
@media (max-width: 374px) {
    .photo-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .site-btn {
        padding: 0.875rem 0.5rem;
        font-size: 0.938rem;
    }
}
