* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 0;
    margin: 0;
    transition: background 0.3s ease;
    display: flex;
    flex-direction: column;
}

body.dark-mode {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

.app-header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 15px 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
    transition: background 0.3s ease;
}

body.dark-mode .app-header {
    background: rgba(26, 26, 46, 0.95);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.app-title {
    margin: 0;
    font-size: 24px;
    color: #333;
    font-weight: 700;
    transition: color 0.3s ease;
}

body.dark-mode .app-title {
    color: #fff;
}

.dark-mode-toggle {
    background: #f0f0f0;
    border: none;
    border-radius: 50px;
    padding: 10px 20px;
    cursor: pointer;
    font-size: 20px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 5px;
}

body.dark-mode .dark-mode-toggle {
    background: #2d3748;
}

.dark-mode-toggle:hover {
    transform: scale(1.05);
}

.icon-dark {
    display: none;
}

body.dark-mode .icon-light {
    display: none;
}

body.dark-mode .icon-dark {
    display: inline;
}

.container {
    max-width: 1400px;
    margin: 20px auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    padding: 0 20px 20px 20px;
    flex: 1;
}

.editor-panel, .preview-panel {
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transition: background 0.3s ease, color 0.3s ease;
}

body.dark-mode .editor-panel,
body.dark-mode .preview-panel {
    background: #1e1e2e;
    color: #e0e0e0;
}

h2 {
    margin-bottom: 20px;
    color: #333;
    font-size: 24px;
    transition: color 0.3s ease;
}

body.dark-mode h2 {
    color: #fff;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.preview-header h2 {
    margin: 0;
}

.phone-selector {
    display: flex;
    align-items: center;
    gap: 10px;
}

.phone-selector label {
    font-size: 14px;
    font-weight: 600;
    color: #666;
    white-space: nowrap;
}

body.dark-mode .phone-selector label {
    color: #aaa;
}

.phone-model-select {
    padding: 8px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 200px;
}

body.dark-mode .phone-model-select {
    background: #2d3748;
    border-color: #4a5568;
    color: #e0e0e0;
}

.phone-model-select:focus {
    outline: none;
    border-color: #06c755;
}

body.dark-mode .phone-model-select option {
    background: #2d3748;
    color: #e0e0e0;
}

body.dark-mode .phone-model-select optgroup {
    background: #1e1e2e;
    color: #06c755;
    font-weight: bold;
}

#jsonInput {
    width: 100%;
    height: 500px;
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    resize: vertical;
    transition: all 0.3s ease;
    background: white;
    color: #333;
}

body.dark-mode #jsonInput {
    background: #2d3748;
    border-color: #4a5568;
    color: #e0e0e0;
}

#jsonInput:focus {
    outline: none;
    border-color: #06c755;
}

.btn-primary {
    width: 100%;
    padding: 15px;
    margin-top: 15px;
    background: #06c755;
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    background: #05b04b;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(6, 199, 85, 0.3);
}

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

.btn-secondary {
    width: 100%;
    padding: 12px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

.btn-secondary:active {
    transform: translateY(0);
}

.btn-primary:disabled,
.btn-secondary:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

body.dark-mode .btn-secondary {
    background: #5568d3;
}

body.dark-mode .btn-secondary:hover {
    background: #667eea;
}

.app-footer {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 27px 20px;
    text-align: center;
    margin-top: auto;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    position: sticky;
    bottom: 0;
    z-index: 100;
}

body.dark-mode .app-footer {
    background: rgba(26, 26, 46, 0.95);
    border-top-color: rgba(255, 255, 255, 0.1);
}

.app-footer p {
    margin: 0;
    color: #666;
    font-size: 14px;
    transition: color 0.3s ease;
    white-space: nowrap;
}

body.dark-mode .app-footer p {
    color: #aaa;
}

.app-footer strong {
    color: #06c755;
    font-weight: 600;
}

body.dark-mode .app-footer strong {
    color: #06c755;
}

.footer-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.footer-links {
    display: flex;
    align-items: center;
    gap: 10px;
}

.footer-links a {
    color: #667eea;
    text-decoration: none;
    font-size: 13px;
    transition: all 0.3s ease;
    padding: 3px 8px;
    border-radius: 5px;
    white-space: nowrap;
}

.footer-links a:hover {
    color: #06c755;
    background: rgba(6, 199, 85, 0.1);
}

body.dark-mode .footer-links a {
    color: #667eea;
}

body.dark-mode .footer-links a:hover {
    color: #06c755;
    background: rgba(6, 199, 85, 0.2);
}

.footer-links span {
    color: #ccc;
    font-size: 12px;
}

body.dark-mode .footer-links span {
    color: #666;
}

.error-msg {
    margin-top: 15px;
    padding: 15px;
    background: #ffe6e6;
    border-left: 4px solid #ff4444;
    border-radius: 5px;
    color: #cc0000;
    display: none;
}

body.dark-mode .error-msg {
    background: #4a1f1f;
    border-left-color: #ff6b6b;
    color: #ff6b6b;
}

.error-msg.show {
    display: block;
}

.phone-frame {
    width: 375px;
    margin: 0 auto;
    background: #f5f5f5;
    border-radius: 40px;
    padding: 15px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    position: relative;
    transition: all 0.3s ease;
}

body.dark-mode .phone-frame {
    background: #2d3748;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

/* Phone Models */
.phone-frame.iphone-14-pro-max,
.phone-frame.iphone-14-pro {
    width: 430px;
    border-radius: 55px;
}

.phone-frame.iphone-14,
.phone-frame.iphone-13,
.phone-frame.iphone-12 {
    width: 390px;
    border-radius: 47px;
}

.phone-frame.iphone-se {
    width: 375px;
    border-radius: 20px;
}

.phone-frame.samsung-s23-ultra {
    width: 420px;
    border-radius: 45px;
}

.phone-frame.samsung-s23,
.phone-frame.samsung-s22 {
    width: 400px;
    border-radius: 40px;
}

.phone-frame.samsung-a54,
.phone-frame.samsung-a34 {
    width: 395px;
    border-radius: 35px;
}

.phone-frame.pixel-7-pro {
    width: 412px;
    border-radius: 42px;
}

.phone-frame.pixel-7,
.phone-frame.pixel-6 {
    width: 400px;
    border-radius: 40px;
}

.phone-frame.xiaomi-13-pro,
.phone-frame.xiaomi-12 {
    width: 410px;
    border-radius: 40px;
}

.phone-frame.oppo-find-x5,
.phone-frame.oppo-reno-8 {
    width: 405px;
    border-radius: 38px;
}

.phone-frame.vivo-x80 {
    width: 408px;
    border-radius: 40px;
}

.phone-header {
    background: #4a5568;
    border-radius: 25px 25px 0 0;
    overflow: hidden;
    transition: background 0.3s ease;
}

body.dark-mode .phone-header {
    background: #1a202c;
}

.status-bar {
    display: flex;
    justify-content: space-between;
    padding: 8px 15px;
    background: #2d3748;
    color: white;
    font-size: 12px;
}

body.dark-mode .status-bar {
    background: #0f1419;
}

.chat-header {
    padding: 12px 15px;
    color: white;
    font-weight: bold;
    text-align: center;
    background: #4a5568;
}

body.dark-mode .chat-header {
    background: #1a202c;
}

.phone-body {
    background: #e8f5e9;
    height: 300px;
    overflow-y: auto;
    padding: 15px;
    transition: background 0.3s ease;
}

body.dark-mode .phone-body {
    background: #1e3a2e;
}

.chat-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.message-bubble {
    background: white;
    padding: 12px 15px;
    border-radius: 18px;
    max-width: 80%;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    align-self: flex-start;
    transition: background 0.3s ease;
}

body.dark-mode .message-bubble {
    background: #2d3748;
    color: #e0e0e0;
}

.rich-menu-container {
    background: white;
    border-radius: 0 0 25px 25px;
    overflow: hidden;
}

.chat-bar {
    background: #f0f0f0;
    padding: 12px;
    text-align: center;
    font-weight: bold;
    color: #666;
    border-top: 1px solid #ddd;
    cursor: pointer;
    transition: background 0.3s;
}

.chat-bar:hover {
    background: #e8e8e8;
}

.rich-menu {
    position: relative;
    width: 100%;
    background: #fff;
}

#richMenuCanvas {
    width: 100%;
    display: block;
    background: #f9f9f9;
}

#richMenuAreas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.area-overlay {
    position: absolute;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: rgba(0, 0, 0, 0.3);
    font-size: 24px;
}

.area-overlay:hover {
    background: rgba(6, 199, 85, 0.2);
    border-color: #06c755;
    color: #06c755;
}

.area-overlay.active {
    background: rgba(6, 199, 85, 0.3);
    border-color: #06c755;
}

.info-panel {
    margin-top: 20px;
    padding: 15px;
    background: #f9f9f9;
    border-radius: 10px;
    display: none;
    transition: background 0.3s ease;
}

body.dark-mode .info-panel {
    background: #2d3748;
}

.info-panel.show {
    display: block;
}

.info-item {
    margin-bottom: 10px;
    padding: 10px;
    background: white;
    border-radius: 5px;
    border-left: 4px solid #06c755;
    transition: background 0.3s ease;
}

body.dark-mode .info-item {
    background: #1e1e2e;
}

.info-item strong {
    color: #333;
    display: block;
    margin-bottom: 5px;
    transition: color 0.3s ease;
}

body.dark-mode .info-item strong {
    color: #fff;
}

.info-item code {
    background: #f0f0f0;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 12px;
    transition: background 0.3s ease;
}

body.dark-mode .info-item code {
    background: #4a5568;
    color: #e0e0e0;
}

.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid #e0e0e0;
}

body.dark-mode .tabs {
    border-bottom-color: #4a5568;
}

.tab-btn {
    padding: 12px 24px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    color: #666;
    transition: all 0.3s;
}

body.dark-mode .tab-btn {
    color: #aaa;
}

.tab-btn:hover {
    color: #06c755;
}

.tab-btn.active {
    color: #06c755;
    border-bottom-color: #06c755;
}

body.dark-mode .tab-btn.active {
    color: #06c755;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.upload-section {
    margin-bottom: 20px;
}

.upload-area {
    border: 3px dashed #ddd;
    border-radius: 15px;
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    background: #fafafa;
    position: relative;
    min-height: 250px;
    display: flex;
    align-items: center;
    justify-content: center;
}

body.dark-mode .upload-area {
    background: #2d3748;
    border-color: #4a5568;
}

.upload-area:hover {
    border-color: #06c755;
    background: #f0fff4;
}

body.dark-mode .upload-area:hover {
    background: #1e3a2e;
    border-color: #06c755;
}

.upload-area.dragover {
    border-color: #06c755;
    background: #e6ffe6;
}

body.dark-mode .upload-area.dragover {
    background: #1e3a2e;
}

.upload-placeholder {
    pointer-events: none;
}

.upload-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 15px;
}

.upload-area p {
    font-size: 16px;
    color: #333;
    margin-bottom: 8px;
    transition: color 0.3s ease;
}

body.dark-mode .upload-area p {
    color: #e0e0e0;
}

.upload-area small {
    color: #999;
    font-size: 13px;
    transition: color 0.3s ease;
}

body.dark-mode .upload-area small {
    color: #aaa;
}

.preview-image {
    max-width: 100%;
    max-height: 300px;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.form-section {
    margin-bottom: 20px;
}

.form-section label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
    transition: color 0.3s ease;
}

body.dark-mode .form-section label {
    color: #e0e0e0;
}

.form-section h3 {
    margin-bottom: 15px;
    color: #06c755;
    font-size: 18px;
}

.form-control {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s ease;
    background: white;
    color: #333;
}

body.dark-mode .form-control {
    background: #2d3748;
    border-color: #4a5568;
    color: #e0e0e0;
}

.form-control:focus {
    outline: none;
    border-color: #06c755;
}

.input-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.input-group input {
    flex: 1;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
}

.input-group span {
    font-weight: bold;
    color: #666;
}

.area-config {
    background: #f9f9f9;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    border-left: 4px solid #06c755;
    transition: background 0.3s ease;
}

body.dark-mode .area-config {
    background: #2d3748;
}

.area-config-header {
    font-weight: bold;
    margin-bottom: 10px;
    color: #333;
    transition: color 0.3s ease;
}

body.dark-mode .area-config-header {
    color: #fff;
}

.area-config-row {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 10px;
    margin-bottom: 10px;
    align-items: center;
}

.area-config-row label {
    margin: 0;
    font-size: 13px;
    transition: color 0.3s ease;
}

body.dark-mode .area-config-row label {
    color: #aaa;
}

.area-config-row select,
.area-config-row input {
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 13px;
    transition: all 0.3s ease;
    background: white;
    color: #333;
}

body.dark-mode .area-config-row select,
body.dark-mode .area-config-row input {
    background: #1e1e2e;
    border-color: #4a5568;
    color: #e0e0e0;
}

.area-config-row select:focus,
.area-config-row input:focus {
    outline: none;
    border-color: #06c755;
}

.btn-primary:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.detected-info {
    background: #e6f7ff;
    border: 2px solid #1890ff;
    border-radius: 10px;
    padding: 20px;
    margin: 20px 0;
    transition: all 0.3s ease;
}

body.dark-mode .detected-info {
    background: #1a2332;
    border-color: #3b82f6;
}

.detected-info h3 {
    color: #1890ff;
    margin-bottom: 15px;
    transition: color 0.3s ease;
}

body.dark-mode .detected-info h3 {
    color: #3b82f6;
}

.detected-info ul {
    list-style: none;
    padding: 0;
}

.detected-info li {
    padding: 8px 0;
    border-bottom: 1px solid #d9d9d9;
    transition: all 0.3s ease;
}

body.dark-mode .detected-info li {
    border-bottom-color: #4a5568;
    color: #e0e0e0;
}

.detected-info li:last-child {
    border-bottom: none;
}

.ocr-progress {
    margin-top: 15px;
    padding: 15px;
    background: #f0f9ff;
    border-radius: 8px;
    border: 1px solid #0ea5e9;
}

.progress-bar {
    width: 100%;
    height: 20px;
    background: #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #06c755, #05b04b);
    width: 0%;
    transition: width 0.3s ease;
}

.ocr-progress p {
    margin: 0;
    color: #0369a1;
    font-size: 14px;
    text-align: center;
}

@media (max-width: 1200px) {
    .container {
        grid-template-columns: 1fr;
        padding: 0 15px 20px 15px;
    }
    
    .preview-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .phone-selector {
        width: 100%;
    }
    
    .phone-model-select {
        width: 100%;
    }
    
    .phone-frame {
        max-width: 100%;
    }
}

@media (max-width: 768px) {
    .app-title {
        font-size: 18px;
    }
    
    .dark-mode-toggle {
        padding: 8px 16px;
        font-size: 18px;
    }
    
    .header-content {
        padding: 0 10px;
    }
    
    .footer-content {
        flex-direction: column;
        gap: 10px;
    }
    
    .footer-links {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .editor-panel,
    .preview-panel {
        padding: 20px;
    }
    
    h2 {
        font-size: 20px;
    }
    
    .phone-frame {
        width: 100% !important;
        max-width: 375px;
    }
}

