# All files / js/pages/company-settings Edit.vue

0% Statements 0/265
0% Branches 0/675
0% Functions 0/95
0% Lines 0/264

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
    588
    589
    590
    591
    592
    593
    594
    595
    596
    597
    598
    599
    600
    601
    602
    603
    604
    605
    606
    607
    608
    609
    610
    611
    612
    613
    614
    615
    616
    617
    618
    619
    620
    621
    622
    623
    624
    625
    626
    627
    628
    629
    630
    631
    632
    633
    634
    635
    636
    637
    638
    639
    640
    641
    642
    643
    644
    645
    646
    647
    648
    649
    650
    651
    652
    653
    654
    655
    656
    657
    658
    659
    660
    661
    662
    663
    664
    665
    666
    667
    668
    669
    670
    671
    672
    673
    674
    675
    676
    677
    678
    679
    680
    681
    682
    683
    684
    685
    686
    687
    688
    689
    690
    691
    692
    693
    694
    695
    696
    697
    698
    699
    700
    701
    702
    703
    704
    705
    706
    707
    708
    709
    710
    711
    712
    713
    714
    715
    716
    717
    718
    719
    720
    721
    722
    723
    724
    725
    726
    727
    728
    729
    730
    731
    732
    733
    734
    735
    736
    737
    738
    739
    740
    741
    742
    743
    744
    745
    746
    747
    748
    749
    750
    751
    752
    753
    754
    755
    756
    757
    758
    759
    760
    761
    762
    763
    764
    765
    766
    767
    768
    769
    770
    771
    772
    773
    774
    775
    776
    777
    778
    779
    780
    781
    782
    783
    784
    785
    786
    787
    788
    789
    790
    791
    792
    793
    794
    795
    796
    797
    798
    799
    800
    801
    802
    803
    804
    805
    806
    807
    808
    809
    810
    811
    812
    813
    814
    815
    816
    817
    818
    819
    820
    821
    822
    823
    824
    825
    826
    827
    828
    829
    830
    831
    832
    833
    834
    835
    836
    837
    838
    839
    840
    841
    842
    843
    844
    845
    846
    847
    848
    849
    850
    851
    852
    853
    854
    855
    856
    857
    858
    859
    860
    861
    862
    863
    864
    865
    866
    867
    868
    869
    870
    871
    872
    873
    874
    875
    876
    877
    878
    879
    880
    881
    882
    883
    884
    885
    886
    887
    888
    889
    890
    891
    892
    893
    894
    895
    896
    897
    898
    899
    900
    901
    902
    903
    904
    905
    906
    907
    908
    909
    910
    911
    912
    913
    914
    915
    916
    917
    918
    919
    920
    921
    922
    923
    924
    925
    926
    927
    928
    929
    930
    931
    932
    933
    934
    935
    936
    937
    938
    939
    940
    941
    942
    943
    944
    945
    946
    947
    948
    949
    950
    951
    952
    953
    954
    955
    956
    957
    958
    959
    960
    961
    962
    963
    964
    965
    966
    967
    968
    969
    970
    971
    972
    973
    974
    975
    976
    977
    978
    979
    980
    981
    982
    983
    984
    985
    986
    987
    988
    989
    990
    991
    992
    993
    994
    995
    996
    997
    998
    999
    1000
    1001
    1002
    1003
    1004
    1005
    1006
    1007
    1008
    1009
    1010
    1011
    1012
    1013
    1014
    1015
    1016
    1017
    1018
    1019
    1020
    1021
    1022
    1023
    1024
    1025
    1026
    1027
    1028
    1029
    1030
    1031
    1032
    1033
    1034
    1035
    1036
    1037
    1038
    1039
    1040
    1041
    1042
    1043
    1044
    1045
    1046
    1047
    1048
    1049
    1050
    1051
    1052
    1053
    1054
    1055
    1056
    1057
    1058
    1059
    1060
    1061
    1062
    1063
    1064
    1065
    1066
    1067
    1068
    1069
    1070
    1071
    1072
    1073
    1074
    1075
    1076
    1077
    1078
    1079
    1080
    1081
    1082
    1083
    1084
    1085
    1086
    1087
    1088
    1089
    1090
    1091
    1092
    1093
    1094
    1095
    1096
    1097
    1098
    1099
    1100
    1101
    1102
    1103
    1104
    1105
    1106
    1107
    1108
    1109
    1110
    1111
    1112
    1113
    1114
    1115
    1116
    1117
    1118
    1119
    1120
    1121
    1122
    1123
    1124
    1125
    1126
    1127
    1128
    1129
    1130
    1131
    1132
    1133
    1134
    1135
    1136
    1137
    1138
    1139
    1140
    1141
    1142
    1143
    1144
    1145
    1146
    1147
    1148
    1149
    1150
    1151
    1152
    1153
    1154
    1155
    1156
    1157
    1158
    1159
    1160
    1161
    1162
    1163
    1164
    1165
    1166
    1167
    1168
    1169
    1170
    1171
    1172
    1173
    1174
    1175
    1176
    1177
    1178
    1179
    1180
    1181
    1182
    1183
    1184
    1185
    1186
    1187
    1188
    1189
    1190
    1191
    1192
    1193
    1194
    1195
    1196
    1197
    1198
    1199
    1200
    1201
    1202
    1203
    1204
    1205
    1206
    1207
    1208
    1209
    1210
    1211
    1212
    1213
    1214
    1215
    1216
    1217
    1218
    1219
    1220
    1221
    1222
    1223
    1224
    1225
    1226
    1227
    1228
    1229
    1230
    1231
    1232
    1233
    1234
    1235
    1236
    1237
    1238
    1239
    1240
    1241
    1242
    1243
    1244
    1245
    1246
    1247
    1248
    1249
    1250
    1251
    1252
    1253
    1254
    1255
    1256
    1257
    1258
    1259
    1260
    1261
    1262
    1263
    1264
    1265
    1266
    1267
    1268
    1269
    1270
    1271
    1272
    1273
    1274
    1275
    1276
    1277
    1278
    1279
    1280
    1281
    1282
    1283
    1284
    1285
    1286
    1287
    1288
    1289
    1290
    1291
    1292
    1293
    1294
    1295
    1296
    1297
    1298
    1299
    1300
    1301
    1302
    1303
    1304
    1305
    1306
    1307
    1308
    1309
    1310
    1311
    1312
    1313
    1314
    1315
    1316
    1317
    1318
    1319
    1320
    1321
    1322
    1323
    1324
    1325
    1326
    1327
    1328
    1329
    1330
    1331
    1332
    1333
    1334
    1335
    1336
    1337
    1338
    1339
    1340
    1341
    1342
    1343
    1344
    1345
    1346
    1347
    1348
    1349
    1350
    1351
    1352
    1353
    1354
    1355
    1356
    1357
    1358
    1359
    1360
    1361
    1362
    1363
    1364
    1365
    1366
    1367
    1368
    1369
    1370
    1371
    1372
    1373
    1374
    1375
    1376
    1377
    1378
    1379
    1380
    1381
    1382
    1383
    1384
    1385
    1386
    1387
    1388
    1389
    1390
    1391
    1392
    1393
    1394
    1395
    1396
    1397
    1398
    1399
    1400
    1401
    1402
    1403
    1404
    1405
    1406
    1407
    1408
    1409
    1410
    1411
    1412
    1413
    1414
    1415
    1416
    1417
    1418
    1419
    1420
    1421
    1422
    1423
    1424
    1425
    1426
    1427
    1428
    1429
    1430
    1431
    1432
    1433
    1434
    1435
    1436
    1437
    1438
    1439
    1440
    1441
    1442
    1443
    1444
    1445
    1446
    1447
    1448
    1449
    1450
    1451
    1452
    1453
    1454
    1455
    1456
    1457
    1458
    1459
    1460
    1461
    1462
    1463
    1464
    1465
    1466
    1467
    1468
    1469
    1470
    1471
    1472
    1473
    1474
    1475
    1476
    1477
    1478
    1479
    1480
    1481
    1482
    1483
    1484
    1485
    1486
    1487
    1488
    1489
    1490
    1491
    1492
    1493
    1494
    1495
    1496
    1497
    1498
    1499
    1500
    1501
    1502
    1503
    1504
    1505
    1506
    1507
    1508
    1509
    1510
    1511
    1512
    1513
    1514
    1515
    1516
    1517
    1518
    1519
    1520
    1521
    1522
    1523
    1524
    1525
    1526
    1527

     <script setup lang="ts">
    import AppLayout from '@/layouts/AppLayout.vue';
    import { Head, Link, useForm } from '@inertiajs/vue3';
    import { ArrowLeft } from 'lucide-vue-next';
    import companySettings from '@/routes/company-settings';
    import { ref, onMounted } from 'vue';

    interface Company {
        id: number;
        name: string;
        email: string;
        phone: string;
        address: string;
        city: string;
        state: string;
        postal_code: string;
        country: string;
        vat_number: string;
        website: string;
        logo_path: string;
        description: string;
        invoice_footer: string;
        jobcard_footer: string;
        quote_footer: string;
        default_invoice_terms: string;
        default_quote_terms: string;
        default_jobcard_terms: string;
        is_active: boolean;
        is_default: boolean;
        enable_pos: boolean;
        enable_document_signing: boolean;
        whatsapp_business_number: string | null;
        bank_name: string | null;
        bank_account_name: string | null;
        bank_account_number: string | null;
        bank_sort_code: string | null;
        created_at: string;
        updated_at: string;
    }

    interface ReminderSettings {
        id: number;
        company_id: number;
        automation_enabled: boolean;
        overdue_invoice_email_enabled: boolean;
        overdue_invoice_sms_enabled: boolean;
        overdue_invoice_days_after_due: number;
        overdue_invoice_frequency_days: number;
        overdue_invoice_email_template: string | null;
        overdue_invoice_sms_template: string | null;
        overdue_invoice_whatsapp_enabled: boolean;
        overdue_invoice_whatsapp_template: string | null;
        overdue_invoice_whatsapp_template_name: string | null;
        overdue_invoice_whatsapp_template_variables: string[] | null;
        expiring_quote_email_enabled: boolean;
        expiring_quote_sms_enabled: boolean;
        expiring_quote_whatsapp_enabled: boolean;
        expiring_quote_days_before: number;
        expiring_quote_email_template: string | null;
        expiring_quote_sms_template: string | null;
        expiring_quote_whatsapp_template: string | null;
        expiring_quote_whatsapp_template_name: string | null;
        expiring_quote_whatsapp_template_variables: string[] | null;
        payment_received_email_enabled: boolean;
        payment_received_sms_enabled: boolean;
        payment_received_whatsapp_enabled: boolean;
        payment_received_email_template: string | null;
        payment_received_sms_template: string | null;
        payment_received_whatsapp_template: string | null;
        payment_received_whatsapp_template_name: string | null;
        payment_received_whatsapp_template_variables: string[] | null;
        invoice_created_email_enabled: boolean;
        invoice_created_sms_enabled: boolean;
        invoice_created_whatsapp_enabled: boolean;
        invoice_created_email_template: string | null;
        invoice_created_sms_template: string | null;
        invoice_created_whatsapp_template: string | null;
        invoice_created_whatsapp_template_name: string | null;
        invoice_created_whatsapp_template_variables: string[] | null;
        quote_created_email_enabled: boolean;
        quote_created_sms_enabled: boolean;
        quote_created_whatsapp_enabled: boolean;
        quote_created_email_template: string | null;
        quote_created_sms_template: string | null;
        quote_created_whatsapp_template: string | null;
        quote_created_whatsapp_template_name: string | null;
        quote_created_whatsapp_template_variables: string[] | null;
        jobcard_created_email_enabled: boolean;
        jobcard_created_sms_enabled: boolean;
        jobcard_created_whatsapp_enabled: boolean;
        jobcard_created_email_template: string | null;
        jobcard_created_sms_template: string | null;
        jobcard_created_whatsapp_template: string | null;
        jobcard_created_whatsapp_template_name: string | null;
        jobcard_created_whatsapp_template_variables: string[] | null;
        jobcard_status_updated_email_enabled: boolean;
        jobcard_status_updated_sms_enabled: boolean;
        jobcard_status_updated_whatsapp_enabled: boolean;
        jobcard_status_updated_email_template: string | null;
        jobcard_status_updated_sms_template: string | null;
        jobcard_status_updated_whatsapp_template: string | null;
        jobcard_status_updated_whatsapp_template_name: string | null;
        jobcard_status_updated_whatsapp_template_variables: string[] | null;
    }

    interface Props {
        company: Company;
        reminderSettings?: ReminderSettings;
    }

    const props = defineProps<Props>();

    const form = useForm({
        name: '',
        email: '',
        phone: '',
        address: '',
        city: '',
        state: '',
        postal_code: '',
        country: '',
        vat_number: '',
        website: '',
        description: '',
        invoice_footer: '',
        jobcard_footer: '',
        quote_footer: '',
        default_invoice_terms: '',
        default_quote_terms: '',
        default_jobcard_terms: '',
        is_active: true,
        is_default: false,
        enable_pos: false,
        enable_document_signing: false,
        logo: null as File | null,
        whatsapp_business_number: '',
        bank_name: '',
        bank_account_name: '',
        bank_account_number: '',
        bank_sort_code: '',
    });

    // Initialize form with company data
    onMounted(() => {
        form.name = props.company.name || '';
        form.email = props.company.email || '';
        form.phone = props.company.phone || '';
        form.address = props.company.address || '';
        form.city = props.company.city || '';
        form.state = props.company.state || '';
        form.postal_code = props.company.postal_code || '';
        form.country = props.company.country || '';
        form.vat_number = props.company.vat_number || '';
        form.website = props.company.website || '';
        form.description = props.company.description || '';
        form.invoice_footer = props.company.invoice_footer || '';
        form.jobcard_footer = props.company.jobcard_footer || '';
        form.quote_footer = props.company.quote_footer || '';
        form.default_invoice_terms = props.company.default_invoice_terms || '';
        form.default_quote_terms = props.company.default_quote_terms || '';
        form.default_jobcard_terms = props.company.default_jobcard_terms || '';
        form.is_active = props.company.is_active ?? true;
        form.is_default = props.company.is_default ?? false;
        form.enable_pos = props.company.enable_pos ?? false;
        form.enable_document_signing = props.company.enable_document_signing ?? false;
        form.whatsapp_business_number = props.company.whatsapp_business_number || '';
        form.bank_name = props.company.bank_name || '';
        form.bank_account_name = props.company.bank_account_name || '';
        form.bank_account_number = props.company.bank_account_number || '';
        form.bank_sort_code = props.company.bank_sort_code || '';

    });

    const logoPreview = ref<string | null>(props.company.logo_path ? `/storage/${props.company.logo_path}` : null);

    function handleLogoChange(event: Event) {
        const target = event.target as HTMLInputElement;
        if (target.files && target.files[0]) {
            form.logo = target.files[0];

            // Create preview
            const reader = new FileReader();
            reader.onload = (e) => {
                logoPreview.value = e.target?.result as string;
            };
            reader.readAsDataURL(target.files[0]);
        }
    }

    function submit() {

        // Ensure all form fields are properly set before submission
        if (!form.name || form.name.trim() === '') {
            console.error('Name field is empty!');
            return;
        }

        // Submit the form without logo first
        const formWithoutLogo = useForm({
            name: form.name,
            email: form.email,
            phone: form.phone,
            address: form.address,
            city: form.city,
            state: form.state,
            postal_code: form.postal_code,
            country: form.country,
            vat_number: form.vat_number,
            website: form.website,
            description: form.description,
            invoice_footer: form.invoice_footer,
            jobcard_footer: form.jobcard_footer,
            quote_footer: form.quote_footer,
            default_invoice_terms: form.default_invoice_terms,
            default_quote_terms: form.default_quote_terms,
            default_jobcard_terms: form.default_jobcard_terms,
            is_active: form.is_active,
            is_default: form.is_default,
            enable_pos: form.enable_pos,
            enable_document_signing: form.enable_document_signing,
            whatsapp_business_number: form.whatsapp_business_number,
            bank_name: form.bank_name,
            bank_account_name: form.bank_account_name,
            bank_account_number: form.bank_account_number,
            bank_sort_code: form.bank_sort_code,
        });

        formWithoutLogo.put(companySettings.update(props.company.id).url, {
            preserveScroll: true,
            onSuccess: () => {
                // If there's a logo, upload it separately
                if (form.logo) {
                    uploadLogo();
                }
            },
            onError: (errors) => {
                console.error('Form submission errors:', errors);
            }
        });
    }

    function uploadLogo() {
        if (!form.logo) return;

        const logoForm = useForm({
            logo: form.logo,
        });

        logoForm.post(companySettings.uploadLogo(props.company.id).url, {
            preserveScroll: true,
            onSuccess: () => {
            },
            onError: (errors) => {
                console.error('Logo upload errors:', errors);
            }
        });
    }

    // Reminder Settings Form
    const reminderForm = useForm({
        automation_enabled: false,
        overdue_invoice_email_enabled: false,
        overdue_invoice_sms_enabled: false,
        overdue_invoice_days_after_due: 1,
        overdue_invoice_frequency_days: 7,
        overdue_invoice_email_template: '',
        overdue_invoice_sms_template: '',
        overdue_invoice_whatsapp_enabled: false,
        overdue_invoice_whatsapp_template: '',
        overdue_invoice_whatsapp_template_name: '',
        overdue_invoice_whatsapp_template_variables: [] as string[],
        expiring_quote_email_enabled: false,
        expiring_quote_sms_enabled: false,
        expiring_quote_whatsapp_enabled: false,
        expiring_quote_days_before: 3,
        expiring_quote_email_template: '',
        expiring_quote_sms_template: '',
        expiring_quote_whatsapp_template: '',
        expiring_quote_whatsapp_template_name: '',
        expiring_quote_whatsapp_template_variables: [] as string[],
        payment_received_email_enabled: false,
        payment_received_sms_enabled: false,
        payment_received_whatsapp_enabled: false,
        payment_received_email_template: '',
        payment_received_sms_template: '',
        payment_received_whatsapp_template: '',
        payment_received_whatsapp_template_name: '',
        payment_received_whatsapp_template_variables: [] as string[],
        invoice_created_email_enabled: false,
        invoice_created_sms_enabled: false,
        invoice_created_whatsapp_enabled: false,
        invoice_created_email_template: '',
        invoice_created_sms_template: '',
        invoice_created_whatsapp_template: '',
        invoice_created_whatsapp_template_name: '',
        invoice_created_whatsapp_template_variables: [] as string[],
        quote_created_email_enabled: false,
        quote_created_sms_enabled: false,
        quote_created_whatsapp_enabled: false,
        quote_created_email_template: '',
        quote_created_sms_template: '',
        quote_created_whatsapp_template: '',
        quote_created_whatsapp_template_name: '',
        quote_created_whatsapp_template_variables: [] as string[],
        jobcard_created_email_enabled: false,
        jobcard_created_sms_enabled: false,
        jobcard_created_whatsapp_enabled: false,
        jobcard_created_email_template: '',
        jobcard_created_sms_template: '',
        jobcard_created_whatsapp_template: '',
        jobcard_created_whatsapp_template_name: '',
        jobcard_created_whatsapp_template_variables: [] as string[],
        jobcard_status_updated_email_enabled: false,
        jobcard_status_updated_sms_enabled: false,
        jobcard_status_updated_whatsapp_enabled: false,
        jobcard_status_updated_email_template: '',
        jobcard_status_updated_sms_template: '',
        jobcard_status_updated_whatsapp_template: '',
        jobcard_status_updated_whatsapp_template_name: '',
        jobcard_status_updated_whatsapp_template_variables: [] as string[],
    });

    // Initialize reminder form with settings data
    onMounted(() => {
        if (props.reminderSettings) {
            reminderForm.automation_enabled = props.reminderSettings.automation_enabled ?? false;
            reminderForm.overdue_invoice_email_enabled = props.reminderSettings.overdue_invoice_email_enabled ?? false;
            reminderForm.overdue_invoice_sms_enabled = props.reminderSettings.overdue_invoice_sms_enabled ?? false;
            reminderForm.overdue_invoice_days_after_due = props.reminderSettings.overdue_invoice_days_after_due ?? 1;
            reminderForm.overdue_invoice_frequency_days = props.reminderSettings.overdue_invoice_frequency_days ?? 7;
            reminderForm.overdue_invoice_email_template = props.reminderSettings.overdue_invoice_email_template || '';
            reminderForm.overdue_invoice_sms_template = props.reminderSettings.overdue_invoice_sms_template || '';
            reminderForm.overdue_invoice_whatsapp_enabled = props.reminderSettings.overdue_invoice_whatsapp_enabled ?? false;
            reminderForm.overdue_invoice_whatsapp_template = props.reminderSettings.overdue_invoice_whatsapp_template || '';
            reminderForm.overdue_invoice_whatsapp_template_name = props.reminderSettings.overdue_invoice_whatsapp_template_name || '';
            reminderForm.overdue_invoice_whatsapp_template_variables = props.reminderSettings.overdue_invoice_whatsapp_template_variables || [];
            reminderForm.expiring_quote_email_enabled = props.reminderSettings.expiring_quote_email_enabled ?? false;
            reminderForm.expiring_quote_sms_enabled = props.reminderSettings.expiring_quote_sms_enabled ?? false;
            reminderForm.expiring_quote_whatsapp_enabled = props.reminderSettings.expiring_quote_whatsapp_enabled ?? false;
            reminderForm.expiring_quote_days_before = props.reminderSettings.expiring_quote_days_before ?? 3;
            reminderForm.expiring_quote_email_template = props.reminderSettings.expiring_quote_email_template || '';
            reminderForm.expiring_quote_sms_template = props.reminderSettings.expiring_quote_sms_template || '';
            reminderForm.expiring_quote_whatsapp_template = props.reminderSettings.expiring_quote_whatsapp_template || '';
            reminderForm.expiring_quote_whatsapp_template_name = props.reminderSettings.expiring_quote_whatsapp_template_name || '';
            reminderForm.expiring_quote_whatsapp_template_variables = props.reminderSettings.expiring_quote_whatsapp_template_variables || [];
            reminderForm.payment_received_email_enabled = props.reminderSettings.payment_received_email_enabled ?? false;
            reminderForm.payment_received_sms_enabled = props.reminderSettings.payment_received_sms_enabled ?? false;
            reminderForm.payment_received_whatsapp_enabled = props.reminderSettings.payment_received_whatsapp_enabled ?? false;
            reminderForm.payment_received_email_template = props.reminderSettings.payment_received_email_template || '';
            reminderForm.payment_received_sms_template = props.reminderSettings.payment_received_sms_template || '';
            reminderForm.payment_received_whatsapp_template = props.reminderSettings.payment_received_whatsapp_template || '';
            reminderForm.payment_received_whatsapp_template_name = props.reminderSettings.payment_received_whatsapp_template_name || '';
            reminderForm.payment_received_whatsapp_template_variables = props.reminderSettings.payment_received_whatsapp_template_variables || [];
            reminderForm.invoice_created_email_enabled = props.reminderSettings.invoice_created_email_enabled ?? false;
            reminderForm.invoice_created_sms_enabled = props.reminderSettings.invoice_created_sms_enabled ?? false;
            reminderForm.invoice_created_whatsapp_enabled = props.reminderSettings.invoice_created_whatsapp_enabled ?? false;
            reminderForm.invoice_created_email_template = props.reminderSettings.invoice_created_email_template || '';
            reminderForm.invoice_created_sms_template = props.reminderSettings.invoice_created_sms_template || '';
            reminderForm.invoice_created_whatsapp_template = props.reminderSettings.invoice_created_whatsapp_template || '';
            reminderForm.invoice_created_whatsapp_template_name = props.reminderSettings.invoice_created_whatsapp_template_name || '';
            reminderForm.invoice_created_whatsapp_template_variables = props.reminderSettings.invoice_created_whatsapp_template_variables || [];
            reminderForm.quote_created_email_enabled = props.reminderSettings.quote_created_email_enabled ?? false;
            reminderForm.quote_created_sms_enabled = props.reminderSettings.quote_created_sms_enabled ?? false;
            reminderForm.quote_created_whatsapp_enabled = props.reminderSettings.quote_created_whatsapp_enabled ?? false;
            reminderForm.quote_created_email_template = props.reminderSettings.quote_created_email_template || '';
            reminderForm.quote_created_sms_template = props.reminderSettings.quote_created_sms_template || '';
            reminderForm.quote_created_whatsapp_template = props.reminderSettings.quote_created_whatsapp_template || '';
            reminderForm.quote_created_whatsapp_template_name = props.reminderSettings.quote_created_whatsapp_template_name || '';
            reminderForm.quote_created_whatsapp_template_variables = props.reminderSettings.quote_created_whatsapp_template_variables || [];
            reminderForm.jobcard_created_email_enabled = props.reminderSettings.jobcard_created_email_enabled ?? false;
            reminderForm.jobcard_created_sms_enabled = props.reminderSettings.jobcard_created_sms_enabled ?? false;
            reminderForm.jobcard_created_whatsapp_enabled = props.reminderSettings.jobcard_created_whatsapp_enabled ?? false;
            reminderForm.jobcard_created_email_template = props.reminderSettings.jobcard_created_email_template || '';
            reminderForm.jobcard_created_sms_template = props.reminderSettings.jobcard_created_sms_template || '';
            reminderForm.jobcard_created_whatsapp_template = props.reminderSettings.jobcard_created_whatsapp_template || '';
            reminderForm.jobcard_created_whatsapp_template_name = props.reminderSettings.jobcard_created_whatsapp_template_name || '';
            reminderForm.jobcard_created_whatsapp_template_variables = props.reminderSettings.jobcard_created_whatsapp_template_variables || [];
            reminderForm.jobcard_status_updated_email_enabled = props.reminderSettings.jobcard_status_updated_email_enabled ?? false;
            reminderForm.jobcard_status_updated_sms_enabled = props.reminderSettings.jobcard_status_updated_sms_enabled ?? false;
            reminderForm.jobcard_status_updated_whatsapp_enabled = props.reminderSettings.jobcard_status_updated_whatsapp_enabled ?? false;
            reminderForm.jobcard_status_updated_email_template = props.reminderSettings.jobcard_status_updated_email_template || '';
            reminderForm.jobcard_status_updated_sms_template = props.reminderSettings.jobcard_status_updated_sms_template || '';
            reminderForm.jobcard_status_updated_whatsapp_template = props.reminderSettings.jobcard_status_updated_whatsapp_template || '';
            reminderForm.jobcard_status_updated_whatsapp_template_name = props.reminderSettings.jobcard_status_updated_whatsapp_template_name || '';
            reminderForm.jobcard_status_updated_whatsapp_template_variables = props.reminderSettings.jobcard_status_updated_whatsapp_template_variables || [];
        }
    });

    function submitReminderSettings() {
        reminderForm.put(`/company-settings/${props.company.id}/reminder-settings`, {
            preserveScroll: true,
            onSuccess: () => {
            },
            onError: (errors) => {
                console.error('Reminder settings update errors:', errors);
            }
        });
    }

    </script>

    <template>
        <Head :title="`Edit ${props.company.name}`" />

        <AppLayout :breadcrumbs="[
            { title: 'Administration', href: '/administration' },
            { title: 'Company Settings', href: companySettings.index().url },
            { title: props.company.name, href: companySettings.show(props.company.id).url },
            { title: 'Edit', href: '#' }
        ]">
            <div class="p-4">
                <!-- Header -->
                <div class="mb-6 flex items-center gap-4">
                    <Link
                        :href="companySettings.show(props.company.id).url"
                        class="flex items-center gap-2 text-gray-600 hover:text-gray-900"
                    >
                        <ArrowLeft class="h-4 w-4" />
                        Back to Company
                    </Link>
                </div>

                <div class="mx-auto max-w-4xl">
                    <div class="mb-6">
                        <h1 class="text-2xl font-bold text-gray-900">Edit Company</h1>
                        <p class="text-gray-600">Update the details for {{ props.company.name }}</p>
                    </div>

                    <form @submit.prevent="submit" class="space-y-6">
                        <!-- Company Logo -->
                        <div class="rounded-lg border bg-white p-6">
                            <h2 class="mb-4 text-lg font-semibold text-gray-900">Company Logo</h2>
                            <div class="flex items-center gap-6">
                                <div v-if="logoPreview" class="h-20 w-20 overflow-hidden rounded-lg border">
                                    <img :src="logoPreview" alt="Company Logo" class="h-full w-full object-cover" />
                                </div>
                                <div>
                                    <input
                                        type="file"
                                        accept="image/*"
                                        @change="handleLogoChange"
                                        class="block w-full text-sm text-gray-500 file:mr-4 file:py-2 file:px-4 file:rounded-full file:border-0 file:text-sm file:font-semibold file:bg-blue-50 file:text-blue-700 hover:file:bg-blue-100"
                                    />
                                    <p class="mt-1 text-xs text-gray-500">PNG, JPG, GIF up to 2MB</p>
                                </div>
                            </div>
                        </div>

                        <!-- Company Information -->
                        <div class="rounded-lg border bg-white p-6">
                            <h2 class="mb-4 text-lg font-semibold text-gray-900">Company Information</h2>
                            <div class="grid gap-4 md:grid-cols-2">
                                <div>
                                    <label class="mb-1 block text-sm font-medium">Company Name *</label>
                                    <input
                                        v-model="form.name"
                                        type="text"
                                        class="w-full rounded border px-3 py-2"
                                        required
                                    />
                                    <div v-if="form.errors.name" class="mt-1 text-sm text-red-600">{{ form.errors.name }}</div>
                                </div>

                                <div>
                                    <label class="mb-1 block text-sm font-medium">Email</label>
                                    <input
                                        v-model="form.email"
                                        type="email"
                                        class="w-full rounded border px-3 py-2"
                                    />
                                    <div v-if="form.errors.email" class="mt-1 text-sm text-red-600">{{ form.errors.email }}</div>
                                </div>

                                <div>
                                    <label class="mb-1 block text-sm font-medium">Phone</label>
                                    <input
                                        v-model="form.phone"
                                        type="tel"
                                        class="w-full rounded border px-3 py-2"
                                    />
                                    <div v-if="form.errors.phone" class="mt-1 text-sm text-red-600">{{ form.errors.phone }}</div>
                                </div>

                                <div>
                                    <label class="mb-1 block text-sm font-medium">Website</label>
                                    <input
                                        v-model="form.website"
                                        type="url"
                                        class="w-full rounded border px-3 py-2"
                                    />
                                    <div v-if="form.errors.website" class="mt-1 text-sm text-red-600">{{ form.errors.website }}</div>
                                </div>
                            </div>
                        </div>

                        <!-- Address Information -->
                        <div class="rounded-lg border bg-white p-6">
                            <h2 class="mb-4 text-lg font-semibold text-gray-900">Address Information</h2>
                            <div class="space-y-4">
                                <div>
                                    <label class="mb-1 block text-sm font-medium">Address</label>
                                    <textarea
                                        v-model="form.address"
                                        rows="3"
                                        class="w-full rounded border px-3 py-2"
                                    ></textarea>
                                    <div v-if="form.errors.address" class="mt-1 text-sm text-red-600">{{ form.errors.address }}</div>
                                </div>

                                <div class="grid gap-4 md:grid-cols-3">
                                    <div>
                                        <label class="mb-1 block text-sm font-medium">City</label>
                                        <input
                                            v-model="form.city"
                                            type="text"
                                            class="w-full rounded border px-3 py-2"
                                        />
                                        <div v-if="form.errors.city" class="mt-1 text-sm text-red-600">{{ form.errors.city }}</div>
                                    </div>

                                    <div>
                                        <label class="mb-1 block text-sm font-medium">State/Province</label>
                                        <input
                                            v-model="form.state"
                                            type="text"
                                            class="w-full rounded border px-3 py-2"
                                        />
                                        <div v-if="form.errors.state" class="mt-1 text-sm text-red-600">{{ form.errors.state }}</div>
                                    </div>

                                    <div>
                                        <label class="mb-1 block text-sm font-medium">Postal Code</label>
                                        <input
                                            v-model="form.postal_code"
                                            type="text"
                                            class="w-full rounded border px-3 py-2"
                                        />
                                        <div v-if="form.errors.postal_code" class="mt-1 text-sm text-red-600">{{ form.errors.postal_code }}</div>
                                    </div>
                                </div>

                                <div>
                                    <label class="mb-1 block text-sm font-medium">Country</label>
                                    <input
                                        v-model="form.country"
                                        type="text"
                                        class="w-full rounded border px-3 py-2"
                                    />
                                    <div v-if="form.errors.country" class="mt-1 text-sm text-red-600">{{ form.errors.country }}</div>
                                </div>

                                <div>
                                    <label class="mb-1 block text-sm font-medium">VAT Number</label>
                                    <input
                                        v-model="form.vat_number"
                                        type="text"
                                        class="w-full rounded border px-3 py-2"
                                    />
                                    <div v-if="form.errors.vat_number" class="mt-1 text-sm text-red-600">{{ form.errors.vat_number }}</div>
                                </div>
                            </div>
                        </div>

                        <!-- Banking Details -->
                        <div class="rounded-lg border bg-white p-6">
                            <h2 class="mb-4 text-lg font-semibold text-gray-900">Banking Details</h2>
                            <p class="mb-4 text-sm text-gray-600">These details will appear on your PDF documents (invoices, quotes, jobcards).</p>
                            <div class="grid gap-4 md:grid-cols-2">
                                <div>
                                    <label class="mb-1 block text-sm font-medium">Bank Name</label>
                                    <input
                                        v-model="form.bank_name"
                                        type="text"
                                        class="w-full rounded border px-3 py-2"
                                        placeholder="e.g. FNB, Standard Bank, ABSA"
                                    />
                                    <div v-if="form.errors.bank_name" class="mt-1 text-sm text-red-600">{{ form.errors.bank_name }}</div>
                                </div>

                                <div>
                                    <label class="mb-1 block text-sm font-medium">Account Name</label>
                                    <input
                                        v-model="form.bank_account_name"
                                        type="text"
                                        class="w-full rounded border px-3 py-2"
                                        placeholder="Name on the account"
                                    />
                                    <div v-if="form.errors.bank_account_name" class="mt-1 text-sm text-red-600">{{ form.errors.bank_account_name }}</div>
                                </div>

                                <div>
                                    <label class="mb-1 block text-sm font-medium">Account Number</label>
                                    <input
                                        v-model="form.bank_account_number"
                                        type="text"
                                        class="w-full rounded border px-3 py-2"
                                        placeholder="Bank account number"
                                    />
                                    <div v-if="form.errors.bank_account_number" class="mt-1 text-sm text-red-600">{{ form.errors.bank_account_number }}</div>
                                </div>

                                <div>
                                    <label class="mb-1 block text-sm font-medium">Branch Code</label>
                                    <input
                                        v-model="form.bank_sort_code"
                                        type="text"
                                        class="w-full rounded border px-3 py-2"
                                        placeholder="e.g. 250655"
                                    />
                                    <div v-if="form.errors.bank_sort_code" class="mt-1 text-sm text-red-600">{{ form.errors.bank_sort_code }}</div>
                                </div>
                            </div>
                        </div>

                        <!-- Description -->
                        <div class="rounded-lg border bg-white p-6">
                            <h2 class="mb-4 text-lg font-semibold text-gray-900">Description</h2>
                            <div>
                                <label class="mb-1 block text-sm font-medium">Company Description</label>
                                <textarea
                                    v-model="form.description"
                                    rows="4"
                                    class="w-full rounded border px-3 py-2"
                                    placeholder="Tell us about your company..."
                                ></textarea>
                                <div v-if="form.errors.description" class="mt-1 text-sm text-red-600">{{ form.errors.description }}</div>
                            </div>
                        </div>

                        <!-- Document Footers -->
                        <div class="rounded-lg border bg-white p-6">
                            <h2 class="mb-4 text-lg font-semibold text-gray-900">Document Footers</h2>
                            <p class="mb-4 text-sm text-gray-600">These footer texts will appear at the bottom of the respective PDF documents.</p>

                            <div class="space-y-6">
                                <!-- Invoice Footer -->
                                <div>
                                    <label class="mb-1 block text-sm font-medium">Invoice Footer</label>
                                    <textarea
                                        v-model="form.invoice_footer"
                                        rows="4"
                                        class="w-full rounded border px-3 py-2"
                                        placeholder="Enter footer text that will appear on invoice PDFs (e.g., payment terms, thank you message, etc.)"
                                    ></textarea>
                                    <div v-if="form.errors.invoice_footer" class="mt-1 text-sm text-red-600">{{ form.errors.invoice_footer }}</div>
                                    <p class="mt-1 text-xs text-gray-500">This text will appear at the bottom of all invoice PDFs generated for this company.</p>
                                </div>

                                <!-- Quote Footer -->
                                <div>
                                    <label class="mb-1 block text-sm font-medium">Quote Footer</label>
                                    <textarea
                                        v-model="form.quote_footer"
                                        rows="4"
                                        class="w-full rounded border px-3 py-2"
                                        placeholder="Enter footer text that will appear on quote PDFs (e.g., validity period, terms, etc.)"
                                    ></textarea>
                                    <div v-if="form.errors.quote_footer" class="mt-1 text-sm text-red-600">{{ form.errors.quote_footer }}</div>
                                    <p class="mt-1 text-xs text-gray-500">This text will appear at the bottom of all quote PDFs generated for this company.</p>
                                </div>

                                <!-- Jobcard Footer -->
                                <div>
                                    <label class="mb-1 block text-sm font-medium">Jobcard Footer</label>
                                    <textarea
                                        v-model="form.jobcard_footer"
                                        rows="4"
                                        class="w-full rounded border px-3 py-2"
                                        placeholder="Enter footer text that will appear on jobcard PDFs (e.g., completion notes, warranty info, etc.)"
                                    ></textarea>
                                    <div v-if="form.errors.jobcard_footer" class="mt-1 text-sm text-red-600">{{ form.errors.jobcard_footer }}</div>
                                    <p class="mt-1 text-xs text-gray-500">This text will appear at the bottom of all jobcard PDFs generated for this company.</p>
                                </div>
                            </div>
                        </div>

                        <!-- Default Terms & Conditions -->
                        <div class="rounded-lg border bg-white p-6">
                            <h2 class="mb-4 text-lg font-semibold text-gray-900">Default Terms & Conditions</h2>
                            <p class="mb-4 text-sm text-gray-600">These terms will be automatically populated when creating new documents. They can be customized for each individual document.</p>

                            <div class="space-y-6">
                                <!-- Invoice Terms -->
                                <div>
                                    <label class="mb-1 block text-sm font-medium">Default Invoice Terms &amp; Conditions</label>
                                    <textarea
                                        v-model="form.default_invoice_terms"
                                        rows="4"
                                        class="w-full rounded border px-3 py-2"
                                        placeholder="Default legal / commercial terms shown on new invoices (not payment terms like COD — those come from the customer record)"
                                    ></textarea>
                                    <div v-if="form.errors.default_invoice_terms" class="mt-1 text-sm text-red-600">{{ form.errors.default_invoice_terms }}</div>
                                    <p class="mt-1 text-xs text-gray-500">Pre-fills the invoice Terms &amp; Conditions field. Payment terms (COD, Net 30, etc.) use each customer’s payment terms.</p>
                                </div>

                                <!-- Quote Terms -->
                                <div>
                                    <label class="mb-1 block text-sm font-medium">Default Quote Terms</label>
                                    <textarea
                                        v-model="form.default_quote_terms"
                                        rows="4"
                                        class="w-full rounded border px-3 py-2"
                                        placeholder="Enter default terms and conditions for quotes (e.g., validity period, acceptance terms, etc.)"
                                    ></textarea>
                                    <div v-if="form.errors.default_quote_terms" class="mt-1 text-sm text-red-600">{{ form.errors.default_quote_terms }}</div>
                                    <p class="mt-1 text-xs text-gray-500">These terms will be pre-filled when creating new quotes.</p>
                                </div>

                                <!-- Jobcard Terms -->
                                <div>
                                    <label class="mb-1 block text-sm font-medium">Default Jobcard Terms</label>
                                    <textarea
                                        v-model="form.default_jobcard_terms"
                                        rows="4"
                                        class="w-full rounded border px-3 py-2"
                                        placeholder="Enter default terms and conditions for jobcards (e.g., warranty info, completion terms, etc.)"
                                    ></textarea>
                                    <div v-if="form.errors.default_jobcard_terms" class="mt-1 text-sm text-red-600">{{ form.errors.default_jobcard_terms }}</div>
                                    <p class="mt-1 text-xs text-gray-500">These terms will be pre-filled when creating new jobcards.</p>
                                </div>
                            </div>
                        </div>

                        <!-- Settings -->
                        <div class="rounded-lg border bg-white p-6">
                            <h2 class="mb-4 text-lg font-semibold text-gray-900">Settings</h2>
                            <div class="space-y-4">
                                <div>
                                    <label class="flex items-center gap-2">
                                        <input
                                            v-model="form.is_active"
                                            type="checkbox"
                                            class="rounded border-gray-300 text-blue-600 focus:ring-blue-500"
                                        />
                                        <span class="text-sm font-medium text-gray-700">Active (available for selection)</span>
                                    </label>
                                </div>

                                <div>
                                    <label class="flex items-center gap-2">
                                        <input
                                            v-model="form.is_default"
                                            type="checkbox"
                                            class="rounded border-gray-300 text-blue-600 focus:ring-blue-500"
                                        />
                                        <span class="text-sm font-medium text-gray-700">Set as default company</span>
                                    </label>
                                </div>

                                <div>
                                    <label class="flex items-center gap-2">
                                        <input
                                            v-model="form.enable_pos"
                                            type="checkbox"
                                            class="rounded border-gray-300 text-blue-600 focus:ring-blue-500"
                                        />
                                        <span class="text-sm font-medium text-gray-700">Enable Point of Sale (POS)</span>
                                    </label>
                                </div>

                                <div>
                                    <label class="flex items-center gap-2">
                                        <input
                                            v-model="form.enable_document_signing"
                                            type="checkbox"
                                            class="rounded border-gray-300 text-blue-600 focus:ring-blue-500"
                                        />
                                        <span class="text-sm font-medium text-gray-700">Enable document signing (jobcards and invoices)</span>
                                    </label>
                                </div>
                            </div>
                        </div>

                        <!-- Communication Settings -->
                        <div class="rounded-lg border bg-white p-6">
                            <h2 class="mb-4 text-lg font-semibold text-gray-900">Communication Settings</h2>
                            <p class="mb-4 text-sm text-gray-600">Outgoing email transport is configured globally via environment settings. Company name and email are used as sender identity and reply-to.</p>

                            <div class="space-y-4">
                                <div>
                                    <label class="mb-1 block text-sm font-medium">WhatsApp Business Number</label>
                                    <input
                                        v-model="form.whatsapp_business_number"
                                        type="text"
                                        class="w-full rounded border px-3 py-2"
                                        placeholder="+27123456789"
                                    />
                                    <div v-if="form.errors.whatsapp_business_number" class="mt-1 text-sm text-red-600">{{ form.errors.whatsapp_business_number }}</div>
                                    <p class="mt-1 text-xs text-gray-500">WhatsApp Business number for this company (format: +[country code][number])</p>
                                </div>
                            </div>
                        </div>

                        <!-- Automated Reminders -->
                        <div class="rounded-lg border bg-white p-6">
                            <div class="mb-4 flex items-center justify-between">
                                <div>
                                    <h2 class="text-lg font-semibold text-gray-900">Automated Reminders</h2>
                                    <p class="text-sm text-gray-600">Configure automated email and SMS reminders for your business</p>
                                </div>
                            </div>

                            <form @submit.prevent="submitReminderSettings" class="space-y-8">
                                <!-- General Automation Toggle -->
                                <div class="rounded-lg border border-gray-200 bg-gray-50 p-4">
                                    <label class="flex items-center gap-2">
                                        <input
                                            v-model="reminderForm.automation_enabled"
                                            type="checkbox"
                                            class="rounded border-gray-300 text-blue-600 focus:ring-blue-500"
                                        />
                                        <span class="text-base font-semibold text-gray-900">Enable Automation</span>
                                    </label>
                                    <p class="mt-1 text-sm text-gray-600">Master switch to enable/disable all automated reminders</p>
                                </div>

                                <!-- Overdue Invoice Reminders -->
                                <div class="space-y-4 rounded-lg border border-gray-200 p-4">
                                    <h3 class="text-base font-semibold text-gray-900">Overdue Invoice Reminders</h3>

                                    <div class="grid gap-4 md:grid-cols-2">
                                        <div>
                                            <label class="mb-2 block text-sm font-medium">Days After Due Date</label>
                                            <input
                                                v-model.number="reminderForm.overdue_invoice_days_after_due"
                                                type="number"
                                                min="0"
                                                class="w-full rounded border px-3 py-2"
                                                :disabled="!reminderForm.automation_enabled"
                                            />
                                        </div>
                                        <div>
                                            <label class="mb-2 block text-sm font-medium">Frequency (Days)</label>
                                            <input
                                                v-model.number="reminderForm.overdue_invoice_frequency_days"
                                                type="number"
                                                min="1"
                                                class="w-full rounded border px-3 py-2"
                                                :disabled="!reminderForm.automation_enabled"
                                            />
                                            <p class="mt-1 text-xs text-gray-500">How often to send reminders</p>
                                        </div>
                                    </div>

                                    <div class="space-y-4">
                                        <div>
                                            <label class="flex items-center gap-2">
                                                <input
                                                    v-model="reminderForm.overdue_invoice_email_enabled"
                                                    type="checkbox"
                                                    class="rounded border-gray-300 text-blue-600 focus:ring-blue-500"
                                                    :disabled="!reminderForm.automation_enabled"
                                                />
                                                <span class="text-sm font-medium text-gray-700">Enable Email Reminders</span>
                                            </label>
                                        </div>
                                        <div v-if="reminderForm.overdue_invoice_email_enabled">
                                            <label class="mb-1 block text-sm font-medium">Email Template</label>
                                            <textarea
                                                v-model="reminderForm.overdue_invoice_email_template"
                                                rows="6"
                                                class="w-full rounded border px-3 py-2 font-mono text-sm"
                                                placeholder="Available variables: {{customer_name}}, {{invoice_number}}, {{invoice_total}}, {{due_date}}, {{company_name}}"
                                                :disabled="!reminderForm.automation_enabled"
                                            ></textarea>
                                        </div>

                                        <div>
                                            <label class="flex items-center gap-2">
                                                <input
                                                    v-model="reminderForm.overdue_invoice_sms_enabled"
                                                    type="checkbox"
                                                    class="rounded border-gray-300 text-blue-600 focus:ring-blue-500"
                                                    :disabled="!reminderForm.automation_enabled"
                                                />
                                                <span class="text-sm font-medium text-gray-700">Enable SMS Reminders</span>
                                            </label>
                                        </div>
                                        <div v-if="reminderForm.overdue_invoice_sms_enabled">
                                            <label class="mb-1 block text-sm font-medium">SMS Template</label>
                                            <textarea
                                                v-model="reminderForm.overdue_invoice_sms_template"
                                                rows="3"
                                                class="w-full rounded border px-3 py-2 font-mono text-sm"
                                                placeholder="Available variables: {{customer_name}}, {{invoice_number}}, {{invoice_total}}, {{due_date}}, {{company_name}}"
                                                :disabled="!reminderForm.automation_enabled"
                                            ></textarea>
                                            <p class="mt-1 text-xs text-gray-500">Keep SMS messages short (160 characters recommended)</p>
                                        </div>

                                        <div>
                                            <label class="flex items-center gap-2">
                                                <input
                                                    v-model="reminderForm.overdue_invoice_whatsapp_enabled"
                                                    type="checkbox"
                                                    class="rounded border-gray-300 text-blue-600 focus:ring-blue-500"
                                                    :disabled="!reminderForm.automation_enabled"
                                                />
                                                <span class="text-sm font-medium text-gray-700">Enable WhatsApp Reminders</span>
                                            </label>
                                        </div>
                                        <div v-if="reminderForm.overdue_invoice_whatsapp_enabled" class="space-y-3">
                                            <div>
                                                <label class="mb-1 block text-sm font-medium">Template Name *</label>
                                                <input
                                                    v-model="reminderForm.overdue_invoice_whatsapp_template_name"
                                                    type="text"
                                                    class="w-full rounded border px-3 py-2"
                                                    placeholder="e.g., overdue_invoice_reminder"
                                                    :disabled="!reminderForm.automation_enabled"
                                                />
                                            </div>
                                            <div>
                                                <label class="mb-1 block text-sm font-medium">Variables to Send</label>
                                                <select
                                                    v-model="reminderForm.overdue_invoice_whatsapp_template_variables"
                                                    multiple
                                                    class="w-full rounded border px-3 py-2"
                                                    :disabled="!reminderForm.automation_enabled"
                                                >
                                                    <option value="customer_name">Customer Name</option>
                                                    <option value="invoice_number">Invoice Number</option>
                                                    <option value="invoice_total">Invoice Total</option>
                                                    <option value="due_date">Due Date</option>
                                                    <option value="company_name">Company Name</option>
                                                </select>
                                                <p class="mt-1 text-xs text-gray-500">Hold Ctrl/Cmd to select multiple variables</p>
                                            </div>
                                        </div>
                                    </div>
                                </div>

                                <!-- Expiring Quote Reminders -->
                                <div class="space-y-4 rounded-lg border border-gray-200 p-4">
                                    <h3 class="text-base font-semibold text-gray-900">Expiring Quote Reminders</h3>

                                    <div>
                                        <label class="mb-2 block text-sm font-medium">Days Before Expiry</label>
                                        <input
                                            v-model.number="reminderForm.expiring_quote_days_before"
                                            type="number"
                                            min="0"
                                            class="w-full rounded border px-3 py-2"
                                            :disabled="!reminderForm.automation_enabled"
                                        />
                                    </div>

                                    <div class="space-y-4">
                                        <div>
                                            <label class="flex items-center gap-2">
                                                <input
                                                    v-model="reminderForm.expiring_quote_email_enabled"
                                                    type="checkbox"
                                                    class="rounded border-gray-300 text-blue-600 focus:ring-blue-500"
                                                    :disabled="!reminderForm.automation_enabled"
                                                />
                                                <span class="text-sm font-medium text-gray-700">Enable Email Reminders</span>
                                            </label>
                                        </div>
                                        <div v-if="reminderForm.expiring_quote_email_enabled">
                                            <label class="mb-1 block text-sm font-medium">Email Template</label>
                                            <textarea
                                                v-model="reminderForm.expiring_quote_email_template"
                                                rows="6"
                                                class="w-full rounded border px-3 py-2 font-mono text-sm"
                                                placeholder="Available variables: {{customer_name}}, {{quote_number}}, {{quote_total}}, {{expiry_date}}, {{company_name}}"
                                                :disabled="!reminderForm.automation_enabled"
                                            ></textarea>
                                        </div>

                                        <div>
                                            <label class="flex items-center gap-2">
                                                <input
                                                    v-model="reminderForm.expiring_quote_sms_enabled"
                                                    type="checkbox"
                                                    class="rounded border-gray-300 text-blue-600 focus:ring-blue-500"
                                                    :disabled="!reminderForm.automation_enabled"
                                                />
                                                <span class="text-sm font-medium text-gray-700">Enable SMS Reminders</span>
                                            </label>
                                        </div>
                                        <div v-if="reminderForm.expiring_quote_sms_enabled">
                                            <label class="mb-1 block text-sm font-medium">SMS Template</label>
                                            <textarea
                                                v-model="reminderForm.expiring_quote_sms_template"
                                                rows="3"
                                                class="w-full rounded border px-3 py-2 font-mono text-sm"
                                                placeholder="Available variables: {{customer_name}}, {{quote_number}}, {{quote_total}}, {{expiry_date}}, {{company_name}}"
                                                :disabled="!reminderForm.automation_enabled"
                                            ></textarea>
                                        </div>

                                        <div>
                                            <label class="flex items-center gap-2">
                                                <input
                                                    v-model="reminderForm.expiring_quote_whatsapp_enabled"
                                                    type="checkbox"
                                                    class="rounded border-gray-300 text-blue-600 focus:ring-blue-500"
                                                    :disabled="!reminderForm.automation_enabled"
                                                />
                                                <span class="text-sm font-medium text-gray-700">Enable WhatsApp Reminders</span>
                                            </label>
                                        </div>
                                        <div v-if="reminderForm.expiring_quote_whatsapp_enabled" class="space-y-3">
                                            <div>
                                                <label class="mb-1 block text-sm font-medium">Template Name *</label>
                                                <input
                                                    v-model="reminderForm.expiring_quote_whatsapp_template_name"
                                                    type="text"
                                                    class="w-full rounded border px-3 py-2"
                                                    placeholder="e.g., expiring_quote_reminder"
                                                    :disabled="!reminderForm.automation_enabled"
                                                />
                                            </div>
                                            <div>
                                                <label class="mb-1 block text-sm font-medium">Variables to Send</label>
                                                <select
                                                    v-model="reminderForm.expiring_quote_whatsapp_template_variables"
                                                    multiple
                                                    class="w-full rounded border px-3 py-2"
                                                    :disabled="!reminderForm.automation_enabled"
                                                >
                                                    <option value="customer_name">Customer Name</option>
                                                    <option value="quote_number">Quote Number</option>
                                                    <option value="quote_total">Quote Total</option>
                                                    <option value="expiry_date">Expiry Date</option>
                                                    <option value="company_name">Company Name</option>
                                                </select>
                                                <p class="mt-1 text-xs text-gray-500">Hold Ctrl/Cmd to select multiple variables</p>
                                            </div>
                                        </div>
                                    </div>
                                </div>

                                <!-- Payment Received Confirmation -->
                                <div class="space-y-4 rounded-lg border border-gray-200 p-4">
                                    <h3 class="text-base font-semibold text-gray-900">Payment Received Confirmation</h3>

                                    <div class="space-y-4">
                                        <div>
                                            <label class="flex items-center gap-2">
                                                <input
                                                    v-model="reminderForm.payment_received_email_enabled"
                                                    type="checkbox"
                                                    class="rounded border-gray-300 text-blue-600 focus:ring-blue-500"
                                                    :disabled="!reminderForm.automation_enabled"
                                                />
                                                <span class="text-sm font-medium text-gray-700">Enable Email Confirmation</span>
                                            </label>
                                        </div>
                                        <div v-if="reminderForm.payment_received_email_enabled">
                                            <label class="mb-1 block text-sm font-medium">Email Template</label>
                                            <textarea
                                                v-model="reminderForm.payment_received_email_template"
                                                rows="6"
                                                class="w-full rounded border px-3 py-2 font-mono text-sm"
                                                placeholder="Available variables: {{customer_name}}, {{invoice_number}}, {{payment_amount}}, {{payment_date}}, {{company_name}}"
                                                :disabled="!reminderForm.automation_enabled"
                                            ></textarea>
                                        </div>

                                        <div>
                                            <label class="flex items-center gap-2">
                                                <input
                                                    v-model="reminderForm.payment_received_sms_enabled"
                                                    type="checkbox"
                                                    class="rounded border-gray-300 text-blue-600 focus:ring-blue-500"
                                                    :disabled="!reminderForm.automation_enabled"
                                                />
                                                <span class="text-sm font-medium text-gray-700">Enable SMS Confirmation</span>
                                            </label>
                                        </div>
                                        <div v-if="reminderForm.payment_received_sms_enabled">
                                            <label class="mb-1 block text-sm font-medium">SMS Template (Not recommended as networks may block payment SMS's)</label>
                                            <textarea
                                                v-model="reminderForm.payment_received_sms_template"
                                                rows="3"
                                                class="w-full rounded border px-3 py-2 font-mono text-sm"
                                                placeholder="Example: {{company_name}}: Thank you. Ref {{invoice_number}}&#10;&#10;Available variables: {{customer_name}}, {{invoice_number}}, {{payment_amount}}, {{payment_date}}, {{payment_method}}, {{company_name}}&#10;&#10;Tip: Keep it simple. Avoid words like 'Payment', 'Received', 'Allocated', 'Account', or amounts to prevent SMS filtering."
                                                :disabled="!reminderForm.automation_enabled"
                                            ></textarea>
                                        </div>

                                        <div>
                                            <label class="flex items-center gap-2">
                                                <input
                                                    v-model="reminderForm.payment_received_whatsapp_enabled"
                                                    type="checkbox"
                                                    class="rounded border-gray-300 text-blue-600 focus:ring-blue-500"
                                                    :disabled="!reminderForm.automation_enabled"
                                                />
                                                <span class="text-sm font-medium text-gray-700">Enable WhatsApp Confirmation</span>
                                            </label>
                                        </div>
                                        <div v-if="reminderForm.payment_received_whatsapp_enabled" class="space-y-3">
                                            <div>
                                                <label class="mb-1 block text-sm font-medium">Template Name *</label>
                                                <input
                                                    v-model="reminderForm.payment_received_whatsapp_template_name"
                                                    type="text"
                                                    class="w-full rounded border px-3 py-2"
                                                    placeholder="e.g., payment_received"
                                                    :disabled="!reminderForm.automation_enabled"
                                                />
                                            </div>
                                            <div>
                                                <label class="mb-1 block text-sm font-medium">Variables to Send</label>
                                                <select
                                                    v-model="reminderForm.payment_received_whatsapp_template_variables"
                                                    multiple
                                                    class="w-full rounded border px-3 py-2"
                                                    :disabled="!reminderForm.automation_enabled"
                                                >
                                                    <option value="customer_name">Customer Name</option>
                                                    <option value="invoice_number">Invoice Number</option>
                                                    <option value="payment_amount">Payment Amount</option>
                                                    <option value="payment_date">Payment Date</option>
                                                    <option value="payment_method">Payment Method</option>
                                                    <option value="company_name">Company Name</option>
                                                </select>
                                                <p class="mt-1 text-xs text-gray-500">Hold Ctrl/Cmd to select multiple variables</p>
                                            </div>
                                        </div>
                                    </div>
                                </div>

                                <!-- Invoice Created Confirmation -->
                                <div class="space-y-4 rounded-lg border border-gray-200 p-4">
                                    <h3 class="text-base font-semibold text-gray-900">Invoice Created Confirmation</h3>

                                    <div class="space-y-4">
                                        <div>
                                            <label class="flex items-center gap-2">
                                                <input
                                                    v-model="reminderForm.invoice_created_email_enabled"
                                                    type="checkbox"
                                                    class="rounded border-gray-300 text-blue-600 focus:ring-blue-500"
                                                    :disabled="!reminderForm.automation_enabled"
                                                />
                                                <span class="text-sm font-medium text-gray-700">Enable Email Confirmation</span>
                                            </label>
                                        </div>
                                        <div v-if="reminderForm.invoice_created_email_enabled">
                                            <label class="mb-1 block text-sm font-medium">Email Template</label>
                                            <textarea
                                                v-model="reminderForm.invoice_created_email_template"
                                                rows="6"
                                                class="w-full rounded border px-3 py-2 font-mono text-sm"
                                                placeholder="Available variables: {{customer_name}}, {{invoice_number}}, {{invoice_total}}, {{due_date}}, {{company_name}}"
                                                :disabled="!reminderForm.automation_enabled"
                                            ></textarea>
                                        </div>

                                        <div>
                                            <label class="flex items-center gap-2">
                                                <input
                                                    v-model="reminderForm.invoice_created_sms_enabled"
                                                    type="checkbox"
                                                    class="rounded border-gray-300 text-blue-600 focus:ring-blue-500"
                                                    :disabled="!reminderForm.automation_enabled"
                                                />
                                                <span class="text-sm font-medium text-gray-700">Enable SMS Confirmation</span>
                                            </label>
                                        </div>
                                        <div v-if="reminderForm.invoice_created_sms_enabled">
                                            <label class="mb-1 block text-sm font-medium">SMS Template</label>
                                            <textarea
                                                v-model="reminderForm.invoice_created_sms_template"
                                                rows="3"
                                                class="w-full rounded border px-3 py-2 font-mono text-sm"
                                                placeholder="Available variables: {{customer_name}}, {{invoice_number}}, {{invoice_total}}, {{due_date}}, {{company_name}}"
                                                :disabled="!reminderForm.automation_enabled"
                                            ></textarea>
                                        </div>

                                        <div>
                                            <label class="flex items-center gap-2">
                                                <input
                                                    v-model="reminderForm.invoice_created_whatsapp_enabled"
                                                    type="checkbox"
                                                    class="rounded border-gray-300 text-blue-600 focus:ring-blue-500"
                                                    :disabled="!reminderForm.automation_enabled"
                                                />
                                                <span class="text-sm font-medium text-gray-700">Enable WhatsApp Confirmation</span>
                                            </label>
                                        </div>
                                        <div v-if="reminderForm.invoice_created_whatsapp_enabled" class="space-y-3">
                                            <div>
                                                <label class="mb-1 block text-sm font-medium">Template Name *</label>
                                                <input
                                                    v-model="reminderForm.invoice_created_whatsapp_template_name"
                                                    type="text"
                                                    class="w-full rounded border px-3 py-2"
                                                    placeholder="e.g., invoice_created"
                                                    :disabled="!reminderForm.automation_enabled"
                                                />
                                            </div>
                                            <div>
                                                <label class="mb-1 block text-sm font-medium">Variables to Send</label>
                                                <select
                                                    v-model="reminderForm.invoice_created_whatsapp_template_variables"
                                                    multiple
                                                    class="w-full rounded border px-3 py-2"
                                                    :disabled="!reminderForm.automation_enabled"
                                                >
                                                    <option value="customer_name">Customer Name</option>
                                                    <option value="invoice_number">Invoice Number</option>
                                                    <option value="invoice_total">Invoice Total</option>
                                                    <option value="due_date">Due Date</option>
                                                    <option value="company_name">Company Name</option>
                                                </select>
                                                <p class="mt-1 text-xs text-gray-500">Hold Ctrl/Cmd to select multiple variables</p>
                                            </div>
                                        </div>
                                    </div>
                                </div>

                                <!-- Quote Created Confirmation -->
                                <div class="space-y-4 rounded-lg border border-gray-200 p-4">
                                    <h3 class="text-base font-semibold text-gray-900">Quote Created Confirmation</h3>

                                    <div class="space-y-4">
                                        <div>
                                            <label class="flex items-center gap-2">
                                                <input
                                                    v-model="reminderForm.quote_created_email_enabled"
                                                    type="checkbox"
                                                    class="rounded border-gray-300 text-blue-600 focus:ring-blue-500"
                                                    :disabled="!reminderForm.automation_enabled"
                                                />
                                                <span class="text-sm font-medium text-gray-700">Enable Email Confirmation</span>
                                            </label>
                                        </div>
                                        <div v-if="reminderForm.quote_created_email_enabled">
                                            <label class="mb-1 block text-sm font-medium">Email Template</label>
                                            <textarea
                                                v-model="reminderForm.quote_created_email_template"
                                                rows="6"
                                                class="w-full rounded border px-3 py-2 font-mono text-sm"
                                                placeholder="Available variables: {{customer_name}}, {{quote_number}}, {{quote_total}}, {{expiry_date}}, {{company_name}}"
                                                :disabled="!reminderForm.automation_enabled"
                                            ></textarea>
                                        </div>

                                        <div>
                                            <label class="flex items-center gap-2">
                                                <input
                                                    v-model="reminderForm.quote_created_sms_enabled"
                                                    type="checkbox"
                                                    class="rounded border-gray-300 text-blue-600 focus:ring-blue-500"
                                                    :disabled="!reminderForm.automation_enabled"
                                                />
                                                <span class="text-sm font-medium text-gray-700">Enable SMS Confirmation</span>
                                            </label>
                                        </div>
                                        <div v-if="reminderForm.quote_created_sms_enabled">
                                            <label class="mb-1 block text-sm font-medium">SMS Template</label>
                                            <textarea
                                                v-model="reminderForm.quote_created_sms_template"
                                                rows="3"
                                                class="w-full rounded border px-3 py-2 font-mono text-sm"
                                                placeholder="Available variables: {{customer_name}}, {{quote_number}}, {{quote_total}}, {{expiry_date}}, {{company_name}}"
                                                :disabled="!reminderForm.automation_enabled"
                                            ></textarea>
                                        </div>

                                        <div>
                                            <label class="flex items-center gap-2">
                                                <input
                                                    v-model="reminderForm.quote_created_whatsapp_enabled"
                                                    type="checkbox"
                                                    class="rounded border-gray-300 text-blue-600 focus:ring-blue-500"
                                                    :disabled="!reminderForm.automation_enabled"
                                                />
                                                <span class="text-sm font-medium text-gray-700">Enable WhatsApp Confirmation</span>
                                            </label>
                                        </div>
                                        <div v-if="reminderForm.quote_created_whatsapp_enabled" class="space-y-3">
                                            <div>
                                                <label class="mb-1 block text-sm font-medium">Template Name *</label>
                                                <input
                                                    v-model="reminderForm.quote_created_whatsapp_template_name"
                                                    type="text"
                                                    class="w-full rounded border px-3 py-2"
                                                    placeholder="e.g., quote_created"
                                                    :disabled="!reminderForm.automation_enabled"
                                                />
                                            </div>
                                            <div>
                                                <label class="mb-1 block text-sm font-medium">Variables to Send</label>
                                                <select
                                                    v-model="reminderForm.quote_created_whatsapp_template_variables"
                                                    multiple
                                                    class="w-full rounded border px-3 py-2"
                                                    :disabled="!reminderForm.automation_enabled"
                                                >
                                                    <option value="customer_name">Customer Name</option>
                                                    <option value="quote_number">Quote Number</option>
                                                    <option value="quote_total">Quote Total</option>
                                                    <option value="expiry_date">Expiry Date</option>
                                                    <option value="company_name">Company Name</option>
                                                </select>
                                                <p class="mt-1 text-xs text-gray-500">Hold Ctrl/Cmd to select multiple variables</p>
                                            </div>
                                        </div>
                                    </div>
                                </div>

                                <!-- Jobcard Created Confirmation -->
                                <div class="space-y-4 rounded-lg border border-gray-200 p-4">
                                    <h3 class="text-base font-semibold text-gray-900">Jobcard Created Confirmation</h3>

                                    <div class="space-y-4">
                                        <div>
                                            <label class="flex items-center gap-2">
                                                <input
                                                    v-model="reminderForm.jobcard_created_email_enabled"
                                                    type="checkbox"
                                                    class="rounded border-gray-300 text-blue-600 focus:ring-blue-500"
                                                    :disabled="!reminderForm.automation_enabled"
                                                />
                                                <span class="text-sm font-medium text-gray-700">Enable Email Confirmation</span>
                                            </label>
                                        </div>
                                        <div v-if="reminderForm.jobcard_created_email_enabled">
                                            <label class="mb-1 block text-sm font-medium">Email Template</label>
                                            <textarea
                                                v-model="reminderForm.jobcard_created_email_template"
                                                rows="6"
                                                class="w-full rounded border px-3 py-2 font-mono text-sm"
                                                placeholder="Available variables: {{customer_name}}, {{job_number}}, {{jobcard_title}}, {{status}}, {{due_date}}, {{company_name}}"
                                                :disabled="!reminderForm.automation_enabled"
                                            ></textarea>
                                        </div>

                                        <div>
                                            <label class="flex items-center gap-2">
                                                <input
                                                    v-model="reminderForm.jobcard_created_sms_enabled"
                                                    type="checkbox"
                                                    class="rounded border-gray-300 text-blue-600 focus:ring-blue-500"
                                                    :disabled="!reminderForm.automation_enabled"
                                                />
                                                <span class="text-sm font-medium text-gray-700">Enable SMS Confirmation</span>
                                            </label>
                                        </div>
                                        <div v-if="reminderForm.jobcard_created_sms_enabled">
                                            <label class="mb-1 block text-sm font-medium">SMS Template</label>
                                            <textarea
                                                v-model="reminderForm.jobcard_created_sms_template"
                                                rows="3"
                                                class="w-full rounded border px-3 py-2 font-mono text-sm"
                                                placeholder="Available variables: {{customer_name}}, {{job_number}}, {{jobcard_title}}, {{status}}, {{due_date}}, {{company_name}}"
                                                :disabled="!reminderForm.automation_enabled"
                                            ></textarea>
                                        </div>

                                        <div>
                                            <label class="flex items-center gap-2">
                                                <input
                                                    v-model="reminderForm.jobcard_created_whatsapp_enabled"
                                                    type="checkbox"
                                                    class="rounded border-gray-300 text-blue-600 focus:ring-blue-500"
                                                    :disabled="!reminderForm.automation_enabled"
                                                />
                                                <span class="text-sm font-medium text-gray-700">Enable WhatsApp Confirmation</span>
                                            </label>
                                        </div>
                                        <div v-if="reminderForm.jobcard_created_whatsapp_enabled" class="space-y-3">
                                            <div>
                                                <label class="mb-1 block text-sm font-medium">Template Name *</label>
                                                <input
                                                    v-model="reminderForm.jobcard_created_whatsapp_template_name"
                                                    type="text"
                                                    class="w-full rounded border px-3 py-2"
                                                    placeholder="e.g., jobcard_created"
                                                    :disabled="!reminderForm.automation_enabled"
                                                />
                                            </div>
                                            <div>
                                                <label class="mb-1 block text-sm font-medium">Variables to Send</label>
                                                <select
                                                    v-model="reminderForm.jobcard_created_whatsapp_template_variables"
                                                    multiple
                                                    class="w-full rounded border px-3 py-2"
                                                    :disabled="!reminderForm.automation_enabled"
                                                >
                                                    <option value="customer_name">Customer Name</option>
                                                    <option value="job_number">Job Number</option>
                                                    <option value="jobcard_title">Jobcard Title</option>
                                                    <option value="status">Status</option>
                                                    <option value="due_date">Due Date</option>
                                                    <option value="company_name">Company Name</option>
                                                </select>
                                                <p class="mt-1 text-xs text-gray-500">Hold Ctrl/Cmd to select multiple variables</p>
                                            </div>
                                        </div>
                                    </div>
                                </div>

                                <!-- Jobcard Status Updated Confirmation -->
                                <div class="space-y-4 rounded-lg border border-gray-200 p-4">
                                    <h3 class="text-base font-semibold text-gray-900">Jobcard Status Updated Confirmation</h3>

                                    <div class="space-y-4">
                                        <div>
                                            <label class="flex items-center gap-2">
                                                <input
                                                    v-model="reminderForm.jobcard_status_updated_email_enabled"
                                                    type="checkbox"
                                                    class="rounded border-gray-300 text-blue-600 focus:ring-blue-500"
                                                    :disabled="!reminderForm.automation_enabled"
                                                />
                                                <span class="text-sm font-medium text-gray-700">Enable Email Confirmation</span>
                                            </label>
                                        </div>
                                        <div v-if="reminderForm.jobcard_status_updated_email_enabled">
                                            <label class="mb-1 block text-sm font-medium">Email Template</label>
                                            <textarea
                                                v-model="reminderForm.jobcard_status_updated_email_template"
                                                rows="6"
                                                class="w-full rounded border px-3 py-2 font-mono text-sm"
                                                placeholder="Available variables: {{customer_name}}, {{job_number}}, {{jobcard_title}}, {{old_status}}, {{new_status}}, {{company_name}}"
                                                :disabled="!reminderForm.automation_enabled"
                                            ></textarea>
                                        </div>

                                        <div>
                                            <label class="flex items-center gap-2">
                                                <input
                                                    v-model="reminderForm.jobcard_status_updated_sms_enabled"
                                                    type="checkbox"
                                                    class="rounded border-gray-300 text-blue-600 focus:ring-blue-500"
                                                    :disabled="!reminderForm.automation_enabled"
                                                />
                                                <span class="text-sm font-medium text-gray-700">Enable SMS Confirmation</span>
                                            </label>
                                        </div>
                                        <div v-if="reminderForm.jobcard_status_updated_sms_enabled">
                                            <label class="mb-1 block text-sm font-medium">SMS Template</label>
                                            <textarea
                                                v-model="reminderForm.jobcard_status_updated_sms_template"
                                                rows="3"
                                                class="w-full rounded border px-3 py-2 font-mono text-sm"
                                                placeholder="Available variables: {{customer_name}}, {{job_number}}, {{jobcard_title}}, {{old_status}}, {{new_status}}, {{company_name}}"
                                                :disabled="!reminderForm.automation_enabled"
                                            ></textarea>
                                        </div>

                                        <div>
                                            <label class="flex items-center gap-2">
                                                <input
                                                    v-model="reminderForm.jobcard_status_updated_whatsapp_enabled"
                                                    type="checkbox"
                                                    class="rounded border-gray-300 text-blue-600 focus:ring-blue-500"
                                                    :disabled="!reminderForm.automation_enabled"
                                                />
                                                <span class="text-sm font-medium text-gray-700">Enable WhatsApp Confirmation</span>
                                            </label>
                                        </div>
                                        <div v-if="reminderForm.jobcard_status_updated_whatsapp_enabled" class="space-y-3">
                                            <div>
                                                <label class="mb-1 block text-sm font-medium">Template Name *</label>
                                                <input
                                                    v-model="reminderForm.jobcard_status_updated_whatsapp_template_name"
                                                    type="text"
                                                    class="w-full rounded border px-3 py-2"
                                                    placeholder="e.g., jobcard_status_updated"
                                                    :disabled="!reminderForm.automation_enabled"
                                                />
                                            </div>
                                            <div>
                                                <label class="mb-1 block text-sm font-medium">Variables to Send</label>
                                                <select
                                                    v-model="reminderForm.jobcard_status_updated_whatsapp_template_variables"
                                                    multiple
                                                    class="w-full rounded border px-3 py-2"
                                                    :disabled="!reminderForm.automation_enabled"
                                                >
                                                    <option value="customer_name">Customer Name</option>
                                                    <option value="job_number">Job Number</option>
                                                    <option value="jobcard_title">Jobcard Title</option>
                                                    <option value="old_status">Old Status</option>
                                                    <option value="new_status">New Status</option>
                                                    <option value="company_name">Company Name</option>
                                                </select>
                                                <p class="mt-1 text-xs text-gray-500">Hold Ctrl/Cmd to select multiple variables</p>
                                            </div>
                                        </div>
                                    </div>
                                </div>

                                <!-- Reminder Settings Actions -->
                                <div class="flex items-center justify-end gap-4">
                                    <button
                                        type="submit"
                                        :disabled="reminderForm.processing || !reminderForm.automation_enabled"
                                        class="rounded-md bg-blue-600 px-4 py-2 text-white hover:bg-blue-700 disabled:opacity-50"
                                    >
                                        {{ reminderForm.processing ? 'Saving...' : 'Save Reminder Settings' }}
                                    </button>
                                </div>
                            </form>
                        </div>

                        <!-- Form Actions -->
                        <div class="flex items-center justify-end gap-4">
                            <Link
                                :href="companySettings.show(props.company.id).url"
                                class="rounded-md border border-gray-300 px-4 py-2 text-gray-700 hover:bg-gray-50"
                            >
                                Cancel
                            </Link>
                            <button
                                type="submit"
                                :disabled="form.processing"
                                class="rounded-md bg-blue-600 px-4 py-2 text-white hover:bg-blue-700 disabled:opacity-50"
                            >
                                {{ form.processing ? 'Updating...' : 'Update Company' }}
                            </button>
                        </div>
                    </form>
                </div>
            </div>
        </AppLayout>
    </template>