xmpkit 0.1.3

Pure Rust implementation of Adobe XMP Toolkit
Documentation
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
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
<template>
  <el-container class="app-container">
    <el-header>
      <div class="header-content">
        <div class="title-with-logo">
          <img :src="logoPath" alt="XMPKit" class="header-logo" />
          <h1>{{ $t('common.title') }}</h1>
        </div>
        <div class="header-actions">
          <el-tooltip 
            :content="localeTooltip" 
            placement="bottom"
            :trigger="isMobile ? 'manual' : 'hover'"
            v-model:visible="localeTooltipVisible"
            :hide-after="0"
            :show-after="0"
          >
            <el-button
              :icon="localeIcon"
              circle
              @click="handleLocaleClick"
              class="locale-toggle-btn"
            />
          </el-tooltip>
          <el-tooltip 
            :content="themeTooltip" 
            placement="bottom"
            :trigger="isMobile ? 'manual' : 'hover'"
            v-model:visible="themeTooltipVisible"
            :hide-after="0"
            :show-after="0"
          >
            <el-button
              :icon="themeIcon"
              circle
              @click="handleThemeClick"
              class="theme-toggle-btn"
            />
          </el-tooltip>
        </div>
      </div>
    </el-header>
    
    <el-main>
      <!-- File Upload Area -->
      <el-card class="upload-card">
        <el-upload
          ref="uploadRef"
          :auto-upload="false"
          :on-change="handleFileChange"
          :show-file-list="false"
          drag
          accept="image/*,audio/*,video/*"
        >
          <el-icon class="el-icon--upload"><upload-filled /></el-icon>
          <div class="el-upload__text">
            {{ $t('common.upload') }}
          </div>
          <template #tip>
            <div class="el-upload__tip">
              {{ $t('common.uploadTip') }}
            </div>
          </template>
        </el-upload>
      </el-card>

      <!-- File Preview -->
      <el-card v-if="filePreview" class="preview-card">
        <template #header>
          <span>{{ $t('common.filePreview') }}</span>
        </template>
        <div class="preview-container">
          <img v-if="filePreview.type.startsWith('image/')" :src="filePreview.url" :alt="filePreview.name" />
          <video v-else-if="filePreview.type.startsWith('video/')" :src="filePreview.url" controls />
          <audio v-else-if="filePreview.type.startsWith('audio/')" :src="filePreview.url" controls />
          <div v-else class="file-placeholder">
            <p>πŸ“„ {{ filePreview.name }}</p>
            <p class="file-placeholder-tip">{{ $t('common.noPreview') }}</p>
          </div>
        </div>
        <el-descriptions :column="1" border style="margin-top: 20px;">
          <el-descriptions-item :label="$t('common.fileName')">{{ filePreview.name }}</el-descriptions-item>
          <el-descriptions-item :label="$t('common.fileSize')">{{ filePreview.size }} KB</el-descriptions-item>
          <el-descriptions-item :label="$t('common.fileType')">{{ filePreview.type }}</el-descriptions-item>
        </el-descriptions>
      </el-card>

      <!-- Operation Buttons -->
      <el-card v-if="xmpFile" class="controls-card">
        <template #header>
          <span>{{ $t('common.operations') }}</span>
        </template>
        <el-button type="primary" @click="readXmp">
          <el-icon><document /></el-icon>
          {{ $t('common.readXmp') }}
        </el-button>
        <el-button type="success" @click="downloadModifiedFile">
          <el-icon><download /></el-icon>
          {{ $t('common.downloadModified') }}
        </el-button>
        <el-button type="info" @click="revertToOriginal">
          <el-icon><refresh-left /></el-icon>
          {{ $t('common.revert') }}
        </el-button>
        <el-button type="warning" @click="reset">
          <el-icon><delete /></el-icon>
          {{ $t('common.reset') }}
        </el-button>
      </el-card>

      <!-- XMP Properties Display -->
      <el-card v-if="xmpFile" class="xmp-card">
        <template #header>
          <span>{{ $t('common.xmpProperties') }}</span>
        </template>
        <el-empty v-if="!xmpProperties.length" :description="$t('common.noProperties')" />
        <el-descriptions v-else :column="1" border>
          <el-descriptions-item
            v-for="prop in xmpProperties"
            :key="prop.label"
            :label="prop.label"
          >
            {{ prop.value }}
          </el-descriptions-item>
        </el-descriptions>
      </el-card>

      <!-- Namespace Management -->
      <el-collapse v-model="namespaceCollapseActiveNames" class="namespace-card">
        <el-collapse-item name="namespace-management" :title="$t('common.namespaceManagement')">
          <el-form :inline="true" @submit.prevent="handleRegisterNamespace" class="namespace-form">
          <el-form-item :label="$t('common.namespaceUri')">
            <el-input
              v-model="namespaceForm.uri"
              :placeholder="$t('common.namespaceUri')"
              class="namespace-uri-input"
            />
          </el-form-item>
          <el-form-item :label="$t('common.namespacePrefix')">
            <el-input
              v-model="namespaceForm.prefix"
              :placeholder="$t('common.namespacePrefix')"
              class="namespace-prefix-input"
            />
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="handleRegisterNamespace">
              <el-icon><plus /></el-icon>
              {{ $t('common.registerNamespace') }}
            </el-button>
          </el-form-item>
        </el-form>
        
        <el-divider />
        
        <div class="namespace-table-header">
          <span>{{ $t('common.registeredNamespaces') }} ({{ registeredNamespaces.length }})</span>
        </div>
        <el-table :data="registeredNamespaces" stripe style="width: 100%">
          <el-table-column prop="prefix" :label="$t('common.namespacePrefix')" width="150">
            <template #default="{ row }">
              <el-tag type="primary">{{ row.prefix }}</el-tag>
            </template>
          </el-table-column>
          <el-table-column prop="uri" :label="$t('common.namespaceUri')">
            <template #default="{ row }">
              <code class="namespace-uri">{{ row.uri }}</code>
            </template>
          </el-table-column>
        </el-table>
        </el-collapse-item>
      </el-collapse>

      <!-- Edit Properties -->
      <el-card v-if="xmpFile" class="edit-card">
        <template #header>
          <span>{{ $t('common.editProperties') }}</span>
        </template>
        <el-form :model="propertyForm" label-width="120px">
          <el-form-item :label="$t('common.namespaceUri')">
            <el-select
              v-model="propertyForm.namespace"
              :placeholder="$t('common.namespaceUri')"
              filterable
              allow-create
              style="width: 100%"
            >
              <el-option-group
                v-if="customNamespaces.length > 0"
                :label="$t('common.customNamespaces')"
              >
                <el-option
                  v-for="ns in customNamespaces"
                  :key="ns.uri"
                  :label="`${ns.prefix} (${ns.uri})`"
                  :value="ns.uri"
                >
                  <span style="float: left">{{ ns.prefix }}</span>
                  <span style="float: right; color: #8492a6; font-size: 13px">{{ ns.uri }}</span>
                </el-option>
              </el-option-group>
              <el-option-group
                v-if="builtinNamespaces.length > 0"
                :label="$t('common.builtinNamespaces')"
              >
                <el-option
                  v-for="ns in builtinNamespaces"
                  :key="ns.uri"
                  :label="`${ns.prefix} (${ns.uri})`"
                  :value="ns.uri"
                >
                  <span style="float: left">{{ ns.prefix }}</span>
                  <span style="float: right; color: #8492a6; font-size: 13px">{{ ns.uri }}</span>
                </el-option>
              </el-option-group>
            </el-select>
          </el-form-item>
          <el-form-item :label="$t('common.propertyName')">
            <template #label>
              <span>{{ $t('common.propertyName') }}</span>
              <el-tooltip :content="$t('common.propertyNameTip')" placement="top">
                <el-icon style="margin-left: 4px; color: #909399; cursor: help;"><question-filled /></el-icon>
              </el-tooltip>
            </template>
            <el-select
              v-model="propertyForm.property"
              :placeholder="$t('common.propertyName')"
              filterable
              allow-create
              style="width: 100%"
            >
              <el-option
                v-for="prop in commonPropertyNames"
                :key="prop.name"
                :label="prop.label"
                :value="prop.name"
              >
                <span style="float: left">{{ prop.label }}</span>
                <span style="float: right; color: #8492a6; font-size: 13px">{{ prop.name }}</span>
              </el-option>
            </el-select>
            <div v-if="commonPropertyNames.length > 0" style="margin-top: 4px; font-size: 12px; color: #909399;">
              {{ $t('common.availableProperties', { count: commonPropertyNames.length }) }}
            </div>
            <div v-else style="margin-top: 4px; font-size: 12px; color: #909399;">
              {{ $t('common.noCommonProperties') }}
            </div>
          </el-form-item>
          <el-form-item :label="$t('common.propertyValue')">
            <template #label>
              <span>{{ $t('common.propertyValue') }}</span>
              <el-tooltip :content="$t('common.propertyValueTip')" placement="top">
                <el-icon style="margin-left: 4px; color: #909399; cursor: help;"><question-filled /></el-icon>
              </el-tooltip>
            </template>
            <el-input
              v-model="propertyForm.value"
              type="textarea"
              :rows="3"
              :placeholder="$t('common.propertyValue')"
            />
          </el-form-item>
          <el-form-item class="edit-buttons">
            <el-button type="primary" @click="handleSetProperty">
              <el-icon><check /></el-icon>
              {{ $t('common.setProperty') }}
            </el-button>
            <el-button type="danger" @click="handleDeleteProperty">
              <el-icon><delete /></el-icon>
              {{ $t('common.deleteProperty') }}
            </el-button>
          </el-form-item>
        </el-form>
      </el-card>

      <!-- Raw XMP Packet -->
      <el-card v-if="xmpPacket" class="packet-card">
        <template #header>
          <span>{{ $t('common.rawXmpPacket') }}</span>
        </template>
        <el-scrollbar height="400px">
          <pre class="xmp-packet">{{ xmpPacket }}</pre>
        </el-scrollbar>
      </el-card>
    </el-main>
  </el-container>
</template>

<script setup lang="ts">
import { ref, reactive, computed, watch, onMounted, nextTick } from 'vue'
import { useI18n } from 'vue-i18n'
import {
  UploadFilled,
  Document,
  Download,
  RefreshLeft,
  Delete,
  Plus,
  Check,
  QuestionFilled,
  Sunny,
  Moon,
  Monitor,
  Switch
} from '@element-plus/icons-vue'
import { useXmp } from './composables/useXmp'
import { initWasm } from './utils/wasm'

const { locale, t } = useI18n()
const uploadRef = ref()
const namespaceCollapseActiveNames = ref<string[]>([]) // Empty array means collapsed by default
const theme = ref<'auto' | 'light' | 'dark'>('auto')

// Detect mobile device
const isMobile = ref(false)
const localeTooltipVisible = ref(false)
const themeTooltipVisible = ref(false)

const updateIsMobile = () => {
  if (typeof window !== 'undefined') {
    isMobile.value = window.innerWidth <= 768
  }
}

const handleLocaleClick = () => {
  toggleLocale()
  if (isMobile.value) {
    localeTooltipVisible.value = true
    setTimeout(() => {
      localeTooltipVisible.value = false
    }, 1000)
  }
}

const handleThemeClick = () => {
  toggleTheme()
  if (isMobile.value) {
    themeTooltipVisible.value = true
    setTimeout(() => {
      themeTooltipVisible.value = false
    }, 1000)
  }
}

const filePreview = ref<{
  name: string
  size: string
  type: string
  url: string
} | null>(null)

const {
  xmpFile,
  xmpProperties,
  xmpPacket,
  registeredNamespaces,
  builtinNamespaceUris,
  loadFile,
  readXmp,
  setProperty,
  deleteProperty,
  registerNamespace,
  downloadModifiedFile,
  revertToOriginal,
  reset,
  updateRegisteredNamespaces,
  getPropertyValue,
} = useXmp()

const namespaceForm = reactive({
  uri: '',
  prefix: ''
})

const propertyForm = reactive({
  namespace: '',
  property: '',
  value: ''
})

// Separate custom and built-in namespaces
const customNamespaces = computed(() => {
  return registeredNamespaces.value.filter(ns => !builtinNamespaceUris.value.includes(ns.uri))
})

const builtinNamespaces = computed(() => {
  return registeredNamespaces.value.filter(ns => builtinNamespaceUris.value.includes(ns.uri))
})

// Common property names for different namespaces
const commonPropertyNames = computed(() => {
  const namespaceUri = propertyForm.namespace
  
  // XMP Basic namespace
  if (namespaceUri === 'http://ns.adobe.com/xap/1.0/') {
    return [
      { name: 'CreatorTool', label: 'CreatorTool' },
      { name: 'CreateDate', label: 'CreateDate' },
      { name: 'ModifyDate', label: 'ModifyDate' },
      { name: 'MetadataDate', label: 'MetadataDate' },
      { name: 'Identifier', label: 'Identifier' },
      { name: 'Nickname', label: 'Nickname' },
      { name: 'Rating', label: 'Rating' },
      { name: 'Label', label: 'Label' },
    ]
  }
  
  // Dublin Core namespace
  if (namespaceUri === 'http://purl.org/dc/elements/1.1/') {
    return [
      { name: 'title', label: 'Title' },
      { name: 'creator', label: 'Creator' },
      { name: 'subject', label: 'Subject' },
      { name: 'description', label: 'Description' },
      { name: 'publisher', label: 'Publisher' },
      { name: 'contributor', label: 'Contributor' },
      { name: 'date', label: 'Date' },
      { name: 'type', label: 'Type' },
      { name: 'format', label: 'Format' },
      { name: 'identifier', label: 'Identifier' },
      { name: 'source', label: 'Source' },
      { name: 'language', label: 'Language' },
      { name: 'relation', label: 'Relation' },
      { name: 'coverage', label: 'Coverage' },
      { name: 'rights', label: 'Rights' },
    ]
  }
  
  // EXIF namespace
  if (namespaceUri === 'http://ns.adobe.com/exif/1.0/') {
    return [
      { name: 'ExifVersion', label: 'ExifVersion' },
      { name: 'ColorSpace', label: 'ColorSpace' },
      { name: 'PixelXDimension', label: 'PixelXDimension' },
      { name: 'PixelYDimension', label: 'PixelYDimension' },
      { name: 'DateTimeOriginal', label: 'DateTimeOriginal' },
      { name: 'DateTimeDigitized', label: 'DateTimeDigitized' },
      { name: 'ExposureTime', label: 'ExposureTime' },
      { name: 'FNumber', label: 'FNumber' },
      { name: 'ExposureProgram', label: 'ExposureProgram' },
      { name: 'ISOSpeedRatings', label: 'ISOSpeedRatings' },
    ]
  }
  
  // AIGC namespace
  if (namespaceUri === 'http://www.tc260.org.cn/ns/AIGC/1.0/') {
    return [
      { name: 'AIGC', label: 'AIGC (AI Generated Content)' },
    ]
  }
  
  // XMP Rights namespace
  if (namespaceUri === 'http://ns.adobe.com/xap/1.0/rights/') {
    return [
      { name: 'Marked', label: 'Marked' },
      { name: 'WebStatement', label: 'WebStatement' },
      { name: 'UsageTerms', label: 'UsageTerms' },
      { name: 'Certificate', label: 'Certificate' },
      { name: 'Owner', label: 'Owner' },
    ]
  }
  
  // XMP Media Management namespace
  if (namespaceUri === 'http://ns.adobe.com/xap/1.0/mm/') {
    return [
      { name: 'DocumentID', label: 'DocumentID' },
      { name: 'InstanceID', label: 'InstanceID' },
      { name: 'OriginalDocumentID', label: 'OriginalDocumentID' },
      { name: 'History', label: 'History' },
      { name: 'DerivedFrom', label: 'DerivedFrom' },
    ]
  }
  
  // Photoshop namespace
  if (namespaceUri === 'http://ns.adobe.com/photoshop/1.0/') {
    return [
      { name: 'AuthorsPosition', label: 'AuthorsPosition' },
      { name: 'CaptionWriter', label: 'CaptionWriter' },
      { name: 'Category', label: 'Category' },
      { name: 'City', label: 'City' },
      { name: 'Country', label: 'Country' },
      { name: 'Credit', label: 'Credit' },
      { name: 'DateCreated', label: 'DateCreated' },
      { name: 'Headline', label: 'Headline' },
      { name: 'Instructions', label: 'Instructions' },
      { name: 'Source', label: 'Source' },
      { name: 'State', label: 'State' },
      { name: 'TransmissionReference', label: 'TransmissionReference' },
      { name: 'Urgency', label: 'Urgency' },
    ]
  }
  
  // TIFF namespace
  if (namespaceUri === 'http://ns.adobe.com/tiff/1.0/') {
    return [
      { name: 'ImageWidth', label: 'ImageWidth' },
      { name: 'ImageLength', label: 'ImageLength' },
      { name: 'BitsPerSample', label: 'BitsPerSample' },
      { name: 'Compression', label: 'Compression' },
      { name: 'PhotometricInterpretation', label: 'PhotometricInterpretation' },
      { name: 'Orientation', label: 'Orientation' },
      { name: 'SamplesPerPixel', label: 'SamplesPerPixel' },
      { name: 'PlanarConfiguration', label: 'PlanarConfiguration' },
      { name: 'ResolutionUnit', label: 'ResolutionUnit' },
      { name: 'XResolution', label: 'XResolution' },
      { name: 'YResolution', label: 'YResolution' },
    ]
  }
  
  // Empty list for unknown namespaces
  return []
})

const changeLocale = (val: string) => {
  locale.value = val
  localStorage.setItem('locale', val)
}

const toggleLocale = () => {
  const newLocale = locale.value === 'zh-CN' ? 'en-US' : 'zh-CN'
  changeLocale(newLocale)
}

const localeIcon = computed(() => {
  // Use Switch icon for language switching
  return Switch
})

const localeTooltip = computed(() => {
  return locale.value === 'zh-CN' ? 'Switch to English' : 'εˆ‡ζ’εˆ°δΈ­ζ–‡'
})

const toggleTheme = () => {
  // Cycle through: auto -> light -> dark -> auto
  if (theme.value === 'auto') {
    theme.value = 'light'
  } else if (theme.value === 'light') {
    theme.value = 'dark'
  } else {
    theme.value = 'auto'
  }
  localStorage.setItem('theme', theme.value)
  applyTheme(theme.value)
}

const applyTheme = (themeMode: 'auto' | 'light' | 'dark') => {
  const html = document.documentElement
  html.classList.remove('light', 'dark')
  
  if (themeMode === 'light') {
    html.classList.add('light')
  } else if (themeMode === 'dark') {
    html.classList.add('dark')
  }
  // 'auto' means no class, will follow system preference
}

// Computed properties for theme icon and tooltip
const themeIcon = computed(() => {
  if (theme.value === 'light') {
    return Sunny
  } else if (theme.value === 'dark') {
    return Moon
  } else {
    return Monitor
  }
})

const themeTooltip = computed(() => {
  if (theme.value === 'light') {
    return t('common.themeLight')
  } else if (theme.value === 'dark') {
    return t('common.themeDark')
  } else {
    return t('common.themeAuto')
  }
})

// Computed property for logo path based on theme
const logoPath = computed(() => {
  const currentTheme = theme.value === 'auto' 
    ? (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')
    : theme.value
  
  // Use light logo (dark colors) for light theme, and dark logo (bright colors) for dark theme
  // Use BASE_URL to support GitHub Pages subpath deployment
  const baseUrl = import.meta.env.BASE_URL
  return currentTheme === 'light' 
    ? `${baseUrl}assets/logo-icon-light.svg` 
    : `${baseUrl}assets/logo-icon.svg`
})

// Computed property for favicon path based on theme
const faviconPath = computed(() => {
  const currentTheme = theme.value === 'auto' 
    ? (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')
    : theme.value
  
  // Use favicon with circular background optimized for browser tabs
  // Use BASE_URL to support GitHub Pages subpath deployment
  const baseUrl = import.meta.env.BASE_URL
  return currentTheme === 'light' 
    ? `${baseUrl}assets/favicon-light.svg` 
    : `${baseUrl}assets/favicon.svg`
})

// Function to update favicon based on theme
const updateFavicon = (logoPath: string) => {
  let link = document.querySelector("link[rel~='icon']") as HTMLLinkElement
  if (!link) {
    link = document.createElement('link')
    link.rel = 'icon'
    const head = document.getElementsByTagName('head')[0]
    if (head) {
      head.appendChild(link)
    }
  }
  link.href = logoPath
}

// Watch theme changes and update favicon
watch([theme, faviconPath], () => {
  updateFavicon(faviconPath.value)
}, { immediate: true })

const handleFileChange = async (file: { raw: File }) => {
  const result = await loadFile(file.raw)
  if (result) {
    filePreview.value = {
      name: result.fileName,
      size: (file.raw.size / 1024).toFixed(2),
      type: file.raw.type || t('common.fileType'),
      url: URL.createObjectURL(file.raw)
    }
    // Auto-load property value after file is loaded
    if (propertyForm.namespace && propertyForm.property) {
      const value = getPropertyValue(propertyForm.namespace, propertyForm.property)
      if (value !== null) {
        propertyForm.value = value
      } else {
        propertyForm.value = ''
      }
    } else if (propertyForm.namespace && commonPropertyNames.value.length > 0) {
      // If namespace is set but property is not, select first property
      const firstProperty = commonPropertyNames.value[0]
      if (firstProperty) {
        propertyForm.property = firstProperty.name
        const value = getPropertyValue(propertyForm.namespace, firstProperty.name)
        if (value !== null) {
          propertyForm.value = value
        }
      }
    }
  }
}

const handleSetProperty = async () => {
  if (!propertyForm.namespace || !propertyForm.property) {
    return
  }
  const currentNamespace = propertyForm.namespace
  const currentProperty = propertyForm.property
  
  setProperty(propertyForm.namespace, propertyForm.property, propertyForm.value)
  
  // After setting property, reload the value (don't clear the form)
  // Use nextTick to ensure readXmp has completed and reactive updates are done
  await nextTick()
  // Small delay to ensure readXmp completes
  setTimeout(() => {
    if (propertyForm.namespace === currentNamespace && propertyForm.property === currentProperty) {
      const value = getPropertyValue(currentNamespace, currentProperty)
      if (value !== null) {
        propertyForm.value = value
      }
    }
  }, 50)
}

const handleDeleteProperty = () => {
  deleteProperty(propertyForm.namespace, propertyForm.property)
}

const handleRegisterNamespace = () => {
  registerNamespace(namespaceForm.uri, namespaceForm.prefix)
  namespaceForm.uri = ''
  namespaceForm.prefix = ''
}

// Watch namespace changes and auto-select first property with its value
watch(() => propertyForm.namespace, (newNamespace) => {
  if (newNamespace && commonPropertyNames.value.length > 0) {
    // Select the first common property
    const firstProperty = commonPropertyNames.value[0]
    if (firstProperty) {
      propertyForm.property = firstProperty.name
      
      // Try to load the property value if file is loaded
      if (xmpFile.value) {
        const value = getPropertyValue(newNamespace, firstProperty.name)
        if (value !== null) {
          propertyForm.value = value
        } else {
          propertyForm.value = ''
        }
      }
    }
  } else {
    propertyForm.property = ''
    propertyForm.value = ''
  }
})

// Watch property changes and auto-load its value
watch(() => propertyForm.property, (newProperty) => {
  if (newProperty && propertyForm.namespace && xmpFile.value) {
    const value = getPropertyValue(propertyForm.namespace, newProperty)
    if (value !== null) {
      propertyForm.value = value
    } else {
      propertyForm.value = ''
    }
  }
})

onMounted(async () => {
  // Initialize mobile detection
  updateIsMobile()
  window.addEventListener('resize', updateIsMobile)
  
  // Get theme from localStorage or use 'auto'
  const savedTheme = localStorage.getItem('theme') as 'auto' | 'light' | 'dark' | null
  if (savedTheme && ['auto', 'light', 'dark'].includes(savedTheme)) {
    theme.value = savedTheme
  } else {
    theme.value = 'auto'
  }
  applyTheme(theme.value)
  
  // Get locale from localStorage or use system default
  const savedLocale = localStorage.getItem('locale')
  if (savedLocale) {
    locale.value = savedLocale
  } else {
    // Use system language if no saved preference
    const systemLang = navigator.language || navigator.languages?.[0] || 'en-US'
    const detectedLocale = systemLang.startsWith('zh') ? 'zh-CN' : 'en-US'
    locale.value = detectedLocale
    localStorage.setItem('locale', detectedLocale)
  }
  // Initialize WASM and update namespace list
  await initWasm()
  updateRegisteredNamespaces()
  
  // Auto-select custom namespace first, then built-in
  if (!propertyForm.namespace) {
    if (customNamespaces.value.length > 0 && customNamespaces.value[0]) {
      propertyForm.namespace = customNamespaces.value[0].uri
    } else if (builtinNamespaces.value.length > 0 && builtinNamespaces.value[0]) {
      propertyForm.namespace = builtinNamespaces.value[0].uri
    }
  }
  
  // Auto-select first property if namespace is set
  if (propertyForm.namespace && commonPropertyNames.value.length > 0) {
    const firstProperty = commonPropertyNames.value[0]
    if (firstProperty) {
      propertyForm.property = firstProperty.name
      if (xmpFile.value) {
        const value = getPropertyValue(propertyForm.namespace, firstProperty.name)
        if (value !== null) {
          propertyForm.value = value
        }
      }
    }
  }
})
</script>

<style scoped>
.app-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
  background: var(--color-background);
  min-height: 100vh;
  transition: background-color 0.3s ease;
  box-sizing: border-box;
  overflow-x: hidden; /* Prevent horizontal scroll */
  width: 100%;
}

.el-header {
  background: var(--color-card-bg);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 2px 8px var(--color-card-shadow);
  height: auto !important;
  display: flex;
  align-items: center;
  min-height: 64px;
  border: 1px solid var(--color-border);
  transition: all 0.3s ease;
  box-sizing: border-box;
  overflow: hidden; /* Prevent content overflow */
  width: 100%;
}

.header-content {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  width: 100%;
  max-width: 100%;
  gap: 16px;
  box-sizing: border-box;
  overflow: hidden; /* Prevent overflow */
}

.title-with-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0; /* Allow text truncation */
  overflow: hidden; /* Prevent overflow */
  box-sizing: border-box;
}

.header-logo {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
}

.el-header h1 {
  margin: 0;
  color: var(--color-heading);
  line-height: 1.2;
  font-size: 24px;
  font-weight: 600;
  transition: color 0.3s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  flex-shrink: 1;
}

.header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0; /* Prevent shrinking */
  flex-grow: 0; /* Prevent growing */
  width: fit-content; /* Fixed width based on content */
}

.theme-toggle-btn {
  font-size: 18px;
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.theme-toggle-btn:hover {
  transform: scale(1.1);
}

.locale-toggle-btn {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  font-size: 14px;
  font-weight: 600;
}

.theme-toggle-btn {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
}

.el-main {
  padding: 0;
}

.upload-card,
.preview-card,
.controls-card,
.xmp-card,
.namespace-card,
.edit-card,
.packet-card {
  margin-bottom: 24px;
  border-radius: 12px;
  border: 1px solid var(--color-border);
  box-shadow: 0 2px 8px var(--color-card-shadow);
  transition: all 0.3s ease;
  overflow: hidden;
}

.upload-card :deep(.el-card__body),
.preview-card :deep(.el-card__body),
.controls-card :deep(.el-card__body),
.xmp-card :deep(.el-card__body),
.edit-card :deep(.el-card__body),
.packet-card :deep(.el-card__body) {
  background: var(--color-card-bg);
  transition: background-color 0.3s ease;
}

/* Upload tip text - improve visibility in dark mode */
.upload-card :deep(.el-upload__tip) {
  color: var(--color-text);
  transition: color 0.3s ease, opacity 0.3s ease;
}

:root.dark .upload-card :deep(.el-upload__tip) {
  opacity: 0.85;
}

@media (prefers-color-scheme: dark) {
  :root:not(.light) .upload-card :deep(.el-upload__tip) {
    opacity: 0.85;
  }
}

.upload-card :deep(.el-card__header),
.preview-card :deep(.el-card__header),
.controls-card :deep(.el-card__header),
.xmp-card :deep(.el-card__header),
.edit-card :deep(.el-card__header),
.packet-card :deep(.el-card__header) {
  background: var(--color-background-soft);
  border-bottom: 1px solid var(--color-border);
  padding: 16px 20px;
  font-weight: 600;
  color: var(--color-heading);
  transition: all 0.3s ease;
}

.namespace-card {
  background: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  box-shadow: 0 2px 8px var(--color-card-shadow);
  transition: all 0.3s ease;
}

.namespace-card :deep(.el-collapse-item__header) {
  padding-left: 20px;
  padding-right: 20px;
  background: var(--color-background-soft);
  border-bottom: 1px solid var(--color-border);
  font-weight: 600;
  color: var(--color-heading);
  transition: all 0.3s ease;
}

.namespace-card :deep(.el-collapse-item__content) {
  padding: 20px;
  background: var(--color-card-bg);
  transition: background-color 0.3s ease;
}

.preview-container {
  text-align: center;
  padding: 24px;
  background: var(--color-background-mute);
  border-radius: 8px;
  transition: background-color 0.3s ease;
}

.preview-container img,
.preview-container video {
  max-width: 100%;
  max-height: 600px;
  border-radius: 8px;
  box-shadow: 0 4px 12px var(--color-card-shadow);
  transition: box-shadow 0.3s ease;
}

.preview-container audio {
  width: 100%;
  max-width: 500px;
}

.file-placeholder {
  padding: 40px;
  color: var(--color-text);
  transition: color 0.3s ease;
}

.file-placeholder-tip {
  font-size: 12px;
  margin-top: 10px;
}

.namespace-table-header {
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--color-heading);
  font-size: 14px;
  transition: color 0.3s ease;
}

.namespace-uri {
  font-family: 'Courier New', monospace;
  font-size: 12px;
  color: var(--color-text);
  word-break: break-all;
  opacity: 0.8;
  transition: color 0.3s ease, opacity 0.3s ease;
}

/* Improve visibility in dark mode */
:root.dark .namespace-uri {
  opacity: 0.95;
}

@media (prefers-color-scheme: dark) {
  :root:not(.light) .namespace-uri {
    opacity: 0.95;
  }
}

/* Namespace form inputs */
.namespace-uri-input {
  width: 400px;
  max-width: 100%;
}

.namespace-prefix-input {
  width: 200px;
  max-width: 100%;
}

.xmp-packet {
  background: var(--color-background-mute);
  padding: 16px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.6;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--color-text);
  border: 1px solid var(--color-border);
  transition: all 0.3s ease;
  font-family: 'Courier New', monospace;
}

/* Enhanced button styles */
:deep(.el-button) {
  border-radius: 8px;
  transition: all 0.3s ease;
  font-weight: 500;
}

:deep(.el-button:hover) {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px var(--color-card-shadow);
}

:deep(.el-button:active) {
  transform: translateY(0);
}

/* Enhanced input styles */
:deep(.el-input__wrapper) {
  border-radius: 8px;
  transition: all 0.3s ease;
  box-shadow: 0 0 0 1px var(--color-border) inset;
}

:deep(.el-input__wrapper:hover) {
  box-shadow: 0 0 0 1px var(--color-border-hover) inset;
}

:deep(.el-input__wrapper.is-focus) {
  box-shadow: 0 0 0 1px var(--el-color-primary) inset;
}

:deep(.el-select .el-input__wrapper) {
  border-radius: 8px;
}

:deep(.el-textarea__inner) {
  border-radius: 8px;
  transition: all 0.3s ease;
}

/* Enhanced table styles */
:deep(.el-table) {
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--color-border);
}

:deep(.el-table th) {
  background: var(--color-background-soft);
  color: var(--color-heading);
  font-weight: 600;
}

:deep(.el-table td) {
  background: var(--color-card-bg);
  color: var(--color-text);
}

:deep(.el-table--striped .el-table__body tr.el-table__row--striped td) {
  background: var(--color-background-mute);
}

:deep(.el-table tr:hover > td) {
  background: var(--color-background-soft);
}

/* Enhanced card hover effects */
.upload-card:hover,
.preview-card:hover,
.controls-card:hover,
.xmp-card:hover,
.edit-card:hover,
.packet-card:hover {
  box-shadow: 0 4px 16px var(--color-card-shadow);
  transform: translateY(-2px);
}

.namespace-card:hover {
  box-shadow: 0 4px 16px var(--color-card-shadow);
  transform: translateY(-2px);
}

/* Enhanced form styles */
:deep(.el-form-item__label) {
  color: var(--color-heading);
  font-weight: 500;
}

:deep(.el-descriptions__label) {
  color: var(--color-heading);
  font-weight: 500;
}

:deep(.el-descriptions__content) {
  color: var(--color-text);
}

/* Enhanced tag styles */
:deep(.el-tag) {
  border-radius: 6px;
  font-weight: 500;
}

/* Enhanced divider styles */
:deep(.el-divider) {
  border-color: var(--color-border);
}

/* Enhanced scrollbar styles */
:deep(.el-scrollbar__bar) {
  opacity: 0.6;
}

:deep(.el-scrollbar__bar:hover) {
  opacity: 1;
}

/* Mobile Responsive Styles */
@media (max-width: 768px) {
  /* Improve touch targets */
  :deep(.el-button),
  :deep(.el-select),
  :deep(.el-input),
  :deep(.el-textarea) {
    min-height: 44px; /* iOS recommended touch target size */
  }

  /* Header adjustments */
  .el-header {
    padding: 12px 16px;
    min-height: 56px;
  }

  .header-content {
    gap: 12px;
    overflow: hidden; /* Prevent overflow */
    max-width: 100%;
  }

  .title-with-logo {
    gap: 8px;
    min-width: 0; /* Allow flex shrinking */
    overflow: hidden; /* Prevent overflow */
    box-sizing: border-box;
  }

  .header-logo {
    width: 36px;
    height: 36px;
  }

  .el-header h1 {
    font-size: 18px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .header-actions {
    gap: 6px;
    flex-shrink: 0;
    flex-grow: 0;
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    width: fit-content;
  }

  .locale-toggle-btn {
    width: 36px;
    height: 36px;
    font-size: 13px;
    min-width: 36px;
    min-height: 36px;
  }

  .theme-toggle-btn {
    font-size: 16px;
    flex-shrink: 0;
    width: 36px; /* Fixed width for circle button */
    height: 36px;
    min-width: 36px;
    min-height: 36px;
  }

  /* Main content padding */
  .el-main {
    padding: 0 12px;
  }

  /* Card spacing */
  .upload-card,
  .preview-card,
  .controls-card,
  .xmp-card,
  .namespace-card,
  .edit-card,
  .packet-card {
    margin-bottom: 16px;
    border-radius: 8px;
  }

  .upload-card :deep(.el-card__header),
  .preview-card :deep(.el-card__header),
  .controls-card :deep(.el-card__header),
  .xmp-card :deep(.el-card__header),
  .edit-card :deep(.el-card__header),
  .packet-card :deep(.el-card__header) {
    padding: 12px 16px;
    font-size: 14px;
  }

  .upload-card :deep(.el-card__body),
  .preview-card :deep(.el-card__body),
  .controls-card :deep(.el-card__body),
  .xmp-card :deep(.el-card__body),
  .edit-card :deep(.el-card__body),
  .packet-card :deep(.el-card__body) {
    padding: 16px;
  }

  /* Upload area */
  .upload-card :deep(.el-upload-dragger) {
    padding: 30px 20px;
  }

  .upload-card :deep(.el-icon--upload) {
    font-size: 48px;
  }

  .upload-card :deep(.el-upload__text) {
    font-size: 14px;
    margin-top: 12px;
  }

  .upload-card :deep(.el-upload__tip) {
    font-size: 12px;
    margin-top: 8px;
  }

  /* Preview container */
  .preview-container {
    padding: 16px;
  }

  .preview-container img,
  .preview-container video {
    max-height: 400px;
  }

  .preview-container audio {
    max-width: 100%;
  }

  .file-placeholder {
    padding: 24px;
  }

  /* Operation buttons - stack vertically on mobile */
  .controls-card :deep(.el-card__body) {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: stretch; /* Ensure buttons stretch to full width */
  }

  .controls-card :deep(.el-button) {
    width: 100%;
    justify-content: center;
    padding: 12px 20px;
    font-size: 14px;
    margin: 0; /* Remove any default margins */
  }

  /* Edit buttons - stack vertically on mobile */
  .edit-buttons {
    margin-top: 16px;
    margin-bottom: 0;
  }

  .edit-buttons :deep(.el-form-item__content) {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
  }

  .edit-buttons :deep(.el-button) {
    width: 100%;
    justify-content: center;
    padding: 12px 20px;
    font-size: 14px;
    margin: 0 !important; /* Remove any default margins */
  }

  /* Descriptions - single column on mobile */
  :deep(.el-descriptions) {
    --el-descriptions-table-border: 1px solid var(--color-border);
  }

  :deep(.el-descriptions__label) {
    width: 30% !important;
    font-size: 13px;
    padding: 8px 12px;
  }

  :deep(.el-descriptions__content) {
    font-size: 13px;
    padding: 8px 12px;
    word-break: break-word;
  }

  /* Tables - make scrollable on mobile */
  :deep(.el-table) {
    font-size: 13px;
    overflow-x: auto;
    display: block;
    width: 100%;
  }

  :deep(.el-table__body-wrapper),
  :deep(.el-table__header-wrapper) {
    overflow-x: auto;
  }

  :deep(.el-table th),
  :deep(.el-table td) {
    padding: 8px 12px;
    white-space: nowrap;
  }

  :deep(.el-table th:last-child),
  :deep(.el-table td:last-child) {
    white-space: normal;
    word-break: break-word;
  }

  /* Form inputs */
  :deep(.el-input) {
    font-size: 14px;
  }

  :deep(.el-textarea__inner) {
    font-size: 14px;
    padding: 8px 12px;
  }

  /* Namespace card */
  .namespace-card :deep(.el-collapse-item__header) {
    padding: 12px 16px;
    font-size: 14px;
  }

  .namespace-card :deep(.el-collapse-item__content) {
    padding: 16px;
  }

  /* Namespace form - stack vertically on mobile */
  .namespace-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
  }

  .namespace-form :deep(.el-form-item) {
    margin-bottom: 0;
    width: 100%;
  }

  .namespace-form :deep(.el-form-item__label) {
    width: auto !important;
    margin-bottom: 8px;
    display: block;
  }

  .namespace-uri-input,
  .namespace-prefix-input {
    width: 100% !important;
    max-width: 100%;
  }

  .namespace-table-header {
    font-size: 13px;
    margin-bottom: 8px;
  }

  .namespace-uri {
    font-size: 11px;
  }

  /* XMP Packet display */
  .xmp-packet {
    padding: 12px;
    font-size: 12px;
    line-height: 1.5;
  }

  /* Button groups */
  :deep(.el-button-group) {
    display: flex;
    flex-direction: column;
    width: 100%;
  }

  :deep(.el-button-group .el-button) {
    width: 100%;
    margin-left: 0 !important;
    margin-top: 8px;
  }

  :deep(.el-button-group .el-button:first-child) {
    margin-top: 0;
  }

  /* Dialog adjustments */
  :deep(.el-dialog) {
    width: 90% !important;
    margin: 5vh auto !important;
  }

  :deep(.el-dialog__header) {
    padding: 16px;
  }

  :deep(.el-dialog__body) {
    padding: 16px;
    font-size: 14px;
  }

  :deep(.el-dialog__footer) {
    padding: 12px 16px;
  }

  /* Tag adjustments */
  :deep(.el-tag) {
    font-size: 12px;
    padding: 4px 8px;
  }
}

/* Extra small devices (phones, less than 480px) */
@media (max-width: 480px) {
  .el-header {
    padding: 10px 12px;
    min-height: 52px;
  }

  .header-logo {
    width: 32px;
    height: 32px;
  }

  .el-header h1 {
    font-size: 16px;
  }

  .header-actions {
    gap: 4px;
    flex-shrink: 0;
    flex-grow: 0;
    width: fit-content;
  }

  .locale-toggle-btn {
    width: 32px;
    height: 32px;
    font-size: 12px;
    min-width: 32px;
    min-height: 32px;
  }

  .theme-toggle-btn {
    width: 32px;
    height: 32px;
    font-size: 14px;
    min-width: 32px;
    min-height: 32px;
  }

  .el-main {
    padding: 0 8px;
  }

  .upload-card,
  .preview-card,
  .controls-card,
  .xmp-card,
  .namespace-card,
  .edit-card,
  .packet-card {
    margin-bottom: 12px;
    border-radius: 6px;
  }

  .upload-card :deep(.el-card__header),
  .preview-card :deep(.el-card__header),
  .controls-card :deep(.el-card__header),
  .xmp-card :deep(.el-card__header),
  .edit-card :deep(.el-card__header),
  .packet-card :deep(.el-card__header) {
    padding: 10px 12px;
    font-size: 13px;
  }

  .upload-card :deep(.el-card__body),
  .preview-card :deep(.el-card__body),
  .controls-card :deep(.el-card__body),
  .xmp-card :deep(.el-card__body),
  .edit-card :deep(.el-card__body),
  .packet-card :deep(.el-card__body) {
    padding: 12px;
  }

  .preview-container img,
  .preview-container video {
    max-height: 300px;
  }

  .controls-card :deep(.el-button) {
    padding: 10px 16px;
    font-size: 13px;
  }

  .edit-buttons :deep(.el-button) {
    padding: 10px 16px;
    font-size: 13px;
  }

  :deep(.el-descriptions__label) {
    width: 35% !important;
    font-size: 12px;
    padding: 6px 10px;
  }

  :deep(.el-descriptions__content) {
    font-size: 12px;
    padding: 6px 10px;
  }

  :deep(.el-dialog) {
    width: 95% !important;
  }
}

/* Landscape orientation on mobile */
@media (max-width: 768px) and (orientation: landscape) {
  .preview-container img,
  .preview-container video {
    max-height: 50vh;
  }
}

/* Mobile-specific improvements */
@media (max-width: 768px) {
  /* Smooth scrolling */
  html {
    -webkit-overflow-scrolling: touch;
  }

  /* Prevent text selection on buttons for better touch experience */
  .controls-card :deep(.el-button) {
    -webkit-tap-highlight-color: transparent;
    user-select: none;
  }

  /* Improve upload area touch interaction */
  .upload-card :deep(.el-upload-dragger) {
    -webkit-tap-highlight-color: transparent;
  }

  /* Better scrollbar visibility on mobile */
  :deep(.el-scrollbar__bar) {
    opacity: 0.8;
  }

  /* Prevent horizontal scroll on body */
  body {
    overflow-x: hidden;
  }

  /* Ensure cards don't overflow */
  .upload-card,
  .preview-card,
  .controls-card,
  .xmp-card,
  .namespace-card,
  .edit-card,
  .packet-card {
    max-width: 100%;
    box-sizing: border-box;
  }
}
</style>