/* --- CSS Variables (iOS Design System) --- */
:root {
    --primary-blue: #007AFF;       /* iOS Blue */
    --primary-dark: #8B0000;       /* Dark Red */
    --primary-red: #FF0000;        /* Standard Red */
    --alert-red: #FF3B30;          /* iOS Red */
    --alert-light: #FFEBEE;
    --warning-yellow: #FFCC00;
    --warning-light: #FFF3E0;
    --success-green: #34C759;      /* iOS Green */
    --system-gray-6: #F2F2F7;
    --system-gray-5: #E5E5EA;
    --system-gray-4: #D1D1D6;
    --system-gray-3: #C7C7CC;
    --system-gray-2: #AEAEB2;
    --system-gray-1: #8E8E93;
    --text-primary: #1C1C1E;
    --text-secondary: #8E8E93;
    --text-tertiary: #C7C7CC;
    --card-bg: #FFFFFF;
    --card-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
    --border-radius-sm: 10px;
    --border-radius-md: 14px;
    --border-radius-lg: 18px;
    --border-radius-xl: 24px;
}

/* --- Reset & Base Styles --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #E5E5E5;
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- App Container --- */
.app-container {
    max-width: 480px;
    min-height: 100vh;
    margin: 0 auto;
    background-color: var(--system-gray-6);
    position: relative;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.1);
    overflow-x: hidden;
}

/* --- Utility Classes --- */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.p-3 { padding: 24px; }
.p-2 { padding: 16px; }
.p-1 { padding: 8px; }

/* --- Typography --- */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.2;
}

.title-lg {
    font-size: 28px;
    font-weight: 700;
}

.title-md {
    font-size: 22px;
    font-weight: 600;
}

.title-sm {
    font-size: 17px;
    font-weight: 600;
}

.body-md {
    font-size: 17px;
}

.body-sm {
    font-size: 15px;
}

.caption {
    font-size: 13px;
    color: var(--text-secondary);
}

/* --- Buttons --- */
.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px;
    border: none;
    border-radius: var(--border-radius-md);
    font-size: 17px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    text-decoration: none;
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
}

.btn:active {
    opacity: 0.8;
    transform: scale(0.98);
}

.btn-primary {
    background-color: var(--primary-blue);
    color: white;
}

.btn-secondary {
    background-color: var(--system-gray-5);
    color: var(--primary-blue);
}

.btn-danger {
    background-color: var(--alert-red);
    color: white;
}

.btn-success {
    background-color: var(--success-green);
    color: white;
}

.btn-outline {
    background: transparent;
    color: var(--primary-blue);
    border: 2px solid var(--primary-blue);
}

.btn-small {
    padding: 10px 16px;
    font-size: 15px;
}

/* --- Cards --- */
.card {
    background: var(--card-bg);
    border-radius: var(--border-radius-lg);
    margin: 16px;
    box-shadow: var(--card-shadow);
    border: 1px solid rgba(0, 0, 0, 0.04);
}

.card-header {
    padding: 20px 20px 12px;
    border-bottom: 1px solid var(--system-gray-6);
}

.card-body {
    padding: 16px 20px;
}

.card-footer {
    padding: 12px 20px 20px;
    border-top: 1px solid var(--system-gray-6);
}

/* --- Form Elements --- */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.form-label.required::after {
    content: " *";
    color: var(--alert-red);
}

.form-input, .form-textarea, .form-select {
    width: 100%;
    padding: 14px;
    background-color: var(--system-gray-6);
    border: 1px solid transparent;
    border-radius: var(--border-radius-sm);
    font-size: 17px;
    font-family: inherit;
    transition: all 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
}

.form-input:focus, .form-textarea:focus, .form-select:focus {
    outline: none;
    background-color: white;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

.form-textarea {
    min-height: 100px;
    resize: vertical;
    line-height: 1.4;
}

.form-select {
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%238E8E93'%3E%3Cpath d='M4.7 5.3 8 8.6l3.3-3.3.9.9L8 10.4 3.8 6.2l.9-.9z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-size: 16px;
    padding-right: 44px;
}

/* --- Toggle Switches --- */
.toggle-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    border-bottom: 1px solid var(--system-gray-6);
}

.toggle-container:last-child {
    border-bottom: none;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 17px;
    font-weight: 500;
}

.toggle-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 51px;
    height: 31px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--system-gray-4);
    transition: .3s;
    border-radius: 34px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 27px;
    width: 27px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

input:checked + .toggle-slider {
    background-color: var(--success-green);
}

input:checked + .toggle-slider:before {
    transform: translateX(20px);
}

/* --- Badges & Tags --- */
.badge-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-danger {
    background-color: var(--alert-light);
    color: var(--alert-red);
    border: 1px solid rgba(255, 59, 48, 0.2);
}

.badge-warning {
    background-color: var(--warning-light);
    color: #E65100;
    border: 1px solid rgba(255, 152, 0, 0.2);
}

.badge-success {
    background-color: rgba(52, 199, 89, 0.1);
    color: var(--success-green);
    border: 1px solid rgba(52, 199, 89, 0.2);
}

.badge-info {
    background-color: rgba(0, 122, 255, 0.1);
    color: var(--primary-blue);
    border: 1px solid rgba(0, 122, 255, 0.2);
}

/* --- Alert Banner --- */
.alert-banner {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-red) 100%);
    color: white;
    padding: 32px 24px;
    text-align: center;
    border-bottom-left-radius: var(--border-radius-xl);
    border-bottom-right-radius: var(--border-radius-xl);
    position: relative;
    overflow: hidden;
}

.alert-banner::before {
    content: "✚";
    position: absolute;
    font-size: 200px;
    opacity: 0.05;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
}

.alert-banner i {
    font-size: 48px;
    margin-bottom: 16px;
    position: relative;
    z-index: 1;
    color: white;
}

.alert-title {
    font-size: 28px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 4px;
    position: relative;
    z-index: 1;
    color: white;
}

.alert-subtitle {
    font-size: 15px;
    opacity: 0.9;
    font-weight: 500;
    position: relative;
    z-index: 1;
    color: white;
}

/* --- Device Preview --- */
.device-preview {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

.device-icon {
    width: 64px;
    height: 64px;
    background: var(--system-gray-6);
    border-radius: var(--border-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

.device-icon i {
    font-size: 28px;
}

.device-info h3 {
    font-size: 20px;
    margin-bottom: 4px;
}

.device-info p {
    color: var(--text-secondary);
    font-size: 14px;
}

/* --- Special Instructions --- */
.special-instructions {
    background-color: var(--warning-light);
    border-left: 4px solid var(--warning-yellow);
    padding: 16px;
    border-radius: var(--border-radius-sm);
    margin-top: 16px;
}

.instructions-label {
    font-size: 12px;
    font-weight: 700;
    color: #B00020;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.instructions-content {
    font-size: 15px;
    line-height: 1.5;
    color: #333;
    white-space: pre-line;
}

/* --- Photo Upload Styles --- */
.photo-upload-area {
    border: 2px dashed var(--system-gray-4);
    border-radius: var(--border-radius-md);
    padding: 32px 20px;
    text-align: center;
    background-color: var(--system-gray-6);
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 16px;
}

.photo-upload-area:hover {
    border-color: var(--primary-blue);
    background-color: rgba(0, 122, 255, 0.05);
}

.photo-upload-area i {
    font-size: 40px;
    color: var(--system-gray-3);
    margin-bottom: 12px;
}

.photo-upload-text {
    font-size: 17px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.photo-upload-subtext {
    font-size: 13px;
    color: var(--text-secondary);
}

.photo-preview-container {
    display: none;
    margin-bottom: 16px;
    position: relative;
}

.photo-preview {
    width: 100%;
    height: 200px;
    border-radius: var(--border-radius-md);
    object-fit: cover;
    background-color: var(--system-gray-6);
}

.remove-photo-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    border: none;
    cursor: pointer;
    transition: background 0.2s ease;
}

.remove-photo-btn:hover {
    background: rgba(0, 0, 0, 0.8);
}

.device-photo-container {
    margin: 0 16px 20px;
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    box-shadow: var(--card-shadow);
    height: 200px;
}

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

.no-photo-placeholder {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--system-gray-6) 0%, var(--system-gray-5) 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

.no-photo-placeholder i {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

/* --- Action Bar --- */
.action-bar {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 16px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    display: flex;
    gap: 12px;
    z-index: 1001;
}

/* --- Modal --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
}

.modal-content {
    background: white;
    border-radius: var(--border-radius-xl);
    padding: 24px;
    width: 100%;
    max-width: 340px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.modal-header i {
    font-size: 24px;
    color: var(--primary-blue);
}

.modal-header h3 {
    font-size: 20px;
    font-weight: 600;
}

.modal-body {
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 24px;
}

.modal-actions {
    display: flex;
    gap: 12px;
}

/* --- Success Message --- */
.success-message {
    background-color: rgba(52, 199, 89, 0.1);
    border: 1px solid rgba(52, 199, 89, 0.2);
    border-radius: var(--border-radius-md);
    padding: 16px;
    margin: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    animation: fadeIn 0.3s ease;
}

.success-message i {
    color: var(--success-green);
    font-size: 20px;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* --- Tabs --- */
.tab-container {
    display: flex;
    border-bottom: 1px solid var(--system-gray-5);
    padding: 0 16px;
    background: white;
    position: sticky;
    top: 0;
    z-index: 100;
}

.tab {
    flex: 1;
    text-align: center;
    padding: 16px 0;
    font-weight: 500;
    color: var(--text-secondary);
    border-bottom: 3px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tab.active {
    color: var(--primary-blue);
    border-bottom-color: var(--primary-blue);
}

/* --- Content Area --- */
.content-area {
    padding-bottom: 120px; /* Space for action bar */
}

/* --- App Header --- */
.app-header {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-red) 100%);
    color: white;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-title i {
    font-size: 20px;
}

.header-title h1 {
    font-size: 18px;
    font-weight: 700;
}

.mode-indicator {
    font-size: 13px;
    background: rgba(255, 255, 255, 0.2);
    padding: 4px 12px;
    border-radius: 20px;
}

/* 添加返回链接样式 */
.home-link {
    position: fixed;
    top: 20px;
    left: 20px;
    background: white;
    padding: 10px 16px;
    border-radius: 10px;
    text-decoration: none;
    color: var(--primary-blue);
    font-weight: 500;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    z-index: 1001;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.home-link:hover {
    background: var(--system-gray-6);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}/* =========================================== */
/* 按钮重叠修复样式 */
/* =========================================== */

/* Back to Main链接 - 确保在最前面 */
.home-link {
    z-index: 1001 !important;
}

/* Print按钮样式 */
.print-btn {
    top: 70px !important;
    z-index: 999 !important;
    background: white !important;
}

/* Edit Mode指示器调整 */
.mode-indicator {
    z-index: 1000;
    position: relative;
}

/* 确保action bar在最前面 */
.action-bar {
    z-index: 1000 !important;
}

/* 移动端适配 */
@media (max-width: 768px) {
    .home-link {
        top: 10px;
        left: 10px;
        padding: 8px 12px;
        font-size: 14px;
    }
    
    .print-btn {
        top: 60px !important;
        right: 10px;
        padding: 6px 12px;
        font-size: 14px;
    }
}
/* ========================================== */
/* 按钮重叠修复 - 2025-12-15 */
/* 只调整z-index，不破坏原有功能 */
/* ========================================== */

/* 确保Back to Main在最前面 */
.home-link {
    z-index: 1001 !important;
}

/* 确保Tab导航正常工作 */
.tab {
    cursor: pointer !important;
    position: relative;
    z-index: 100 !important;
}

.tab.active {
    z-index: 101 !important;
}

/* 确保Edit Mode指示器显示正常 */
.mode-indicator {
    position: relative;
    z-index: 1000 !important;
}

/* 确保所有可点击元素正常工作 */
button:not([disabled]), 
a:not([disabled]), 
.tab {
    pointer-events: auto !important;
}
