/* QR Code Decoder Tool Styles */

:root {
    --primary-color: #2563eb;
    --secondary-color: #7c3aed;
    --accent-color: #059669;
    --error-color: #dc2626;
    --warning-color: #d97706;
    --success-color: #059669;
    --background-color: #f8fafc;
    --surface-color: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --shadow-light: 0 1px 3px 0 rgb(0 0 0 / 0.1);
    --shadow-medium: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-heavy: 0 20px 25px -5px rgb(0 0 0 / 0.1);
    --border-radius: 16px;
    --transition: all 0.3s ease;
}

[data-theme="dark"] {
    --background-color: #0f172a;
    --surface-color: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border-color: #334155;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--background-color);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px;
}

.hidden {
    display: none !important;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 3rem;
}

header h1 {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

header .icon {
    font-size: 3.5rem;
}

header p {
    color: var(--text-secondary);
    font-size: 1.2rem;
}

/* Input Methods */
.input-methods {
    background: var(--surface-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-light);
    border: 1px solid var(--border-color);
    margin-bottom: 2rem;
    overflow: hidden;
}

.method-tabs {
    display: flex;
    background: var(--background-color);
    border-bottom: 1px solid var(--border-color);
}

.method-tab {
    flex: 1;
    padding: 1rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    border-bottom: 3px solid transparent;
}

.method-tab:hover {
    color: var(--text-primary);
    background: var(--surface-color);
}

.method-tab.active {
    color: var(--primary-color);
    background: var(--surface-color);
    border-bottom-color: var(--primary-color);
}

.method-content {
    display: none;
    padding: 2rem;
}

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

/* Upload Method */
.upload-area {
    border: 3px dashed var(--border-color);
    border-radius: var(--border-radius);
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: var(--background-color);
}

.upload-area:hover, .upload-area.dragover {
    border-color: var(--primary-color);
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.05), rgba(124, 58, 237, 0.05));
    transform: translateY(-2px);
}

.upload-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.upload-content h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.upload-content p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.browse-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.875rem 2rem;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.browse-btn:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
    box-shadow: var(--shadow-medium);
}

/* Camera Method */
.camera-container {
    position: relative;
    background: #000;
    border-radius: var(--border-radius);
    overflow: hidden;
    margin-bottom: 1.5rem;
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#camera-video {
    width: 100%;
    height: auto;
    max-height: 400px;
    object-fit: cover;
}

.camera-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.scan-frame {
    width: 200px;
    height: 200px;
    border: 3px solid var(--primary-color);
    border-radius: 12px;
    position: relative;
    opacity: 0.8;
}

.scan-frame::before {
    content: '';
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
    border: 2px solid rgba(37, 99, 235, 0.3);
    border-radius: 15px;
    animation: scanPulse 2s infinite;
}

@keyframes scanPulse {
    0%, 100% {
        transform: scale(1);
        opacity: 0.8;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.4;
    }
}

.scan-instruction {
    color: white;
    background: rgba(0, 0, 0, 0.7);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    margin-top: 1rem;
    font-weight: 600;
}

.camera-controls {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.camera-btn {
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: var(--border-radius);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

#start-camera-btn {
    background: var(--accent-color);
    color: white;
}

#start-camera-btn:hover {
    background: #047857;
}

#stop-camera-btn {
    background: var(--error-color);
    color: white;
}

#stop-camera-btn:hover {
    background: #b91c1c;
}

#capture-btn {
    background: var(--primary-color);
    color: white;
}

#capture-btn:hover {
    background: #1d4ed8;
}

/* Paste Method */
.paste-area {
    border: 3px dashed var(--border-color);
    border-radius: var(--border-radius);
    padding: 3rem 2rem;
    text-align: center;
    background: var(--background-color);
    transition: var(--transition);
}

.paste-area.has-clipboard {
    border-color: var(--accent-color);
    background: rgba(5, 150, 105, 0.05);
}

.paste-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.paste-content h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.paste-content p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.paste-btn {
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 0.875rem 2rem;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.paste-btn:hover {
    background: #047857;
    transform: translateY(-1px);
    box-shadow: var(--shadow-medium);
}

/* Processing Status */
.processing-status {
    background: var(--surface-color);
    border-radius: var(--border-radius);
    padding: 2rem;
    text-align: center;
    box-shadow: var(--shadow-light);
    border: 1px solid var(--border-color);
    margin-bottom: 2rem;
}

.processing-animation {
    width: 100px;
    height: 100px;
    margin: 0 auto 1rem;
    position: relative;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: processingPulse 2s infinite;
}

@keyframes processingPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.scanner-line {
    width: 60px;
    height: 3px;
    background: white;
    border-radius: 2px;
    animation: scanLine 1.5s infinite;
}

@keyframes scanLine {
    0% {
        transform: translateY(-10px);
        opacity: 0;
    }
    50% {
        opacity: 1;
    }
    100% {
        transform: translateY(10px);
        opacity: 0;
    }
}

.processing-status p {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 1.1rem;
}

/* Preview Section */
.preview-section {
    background: var(--surface-color);
    border-radius: var(--border-radius);
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-light);
    border: 1px solid var(--border-color);
}

.preview-section h3 {
    margin-bottom: 2rem;
    font-size: 1.5rem;
    color: var(--text-primary);
}

.preview-container {
    position: relative;
    display: inline-block;
    max-width: 100%;
    margin-bottom: 1rem;
}

#preview-image {
    max-width: 100%;
    max-height: 400px;
    border-radius: 12px;
    box-shadow: var(--shadow-medium);
}

.preview-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.qr-highlight {
    position: absolute;
    border: 3px solid var(--accent-color);
    border-radius: 8px;
    background: rgba(5, 150, 105, 0.1);
    animation: highlightPulse 2s infinite;
}

@keyframes highlightPulse {
    0%, 100% {
        opacity: 0.8;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.02);
    }
}

.preview-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}

#image-info {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.secondary-btn {
    background: var(--surface-color);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.secondary-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* Results Section */
.results-section {
    background: var(--surface-color);
    border-radius: var(--border-radius);
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-medium);
    border: 2px solid var(--accent-color);
}

.results-section h3 {
    margin-bottom: 2rem;
    font-size: 1.5rem;
    color: var(--accent-color);
}

.results-container {
    margin-bottom: 2rem;
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.result-type {
    background: var(--primary-color);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
}

.result-actions {
    display: flex;
    gap: 0.5rem;
}

.action-btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.9rem;
}

.copy-btn {
    background: var(--secondary-color);
    color: white;
}

.copy-btn:hover {
    background: #6d28d9;
}

.share-btn {
    background: var(--accent-color);
    color: white;
}

.share-btn:hover {
    background: #047857;
}

.result-content {
    background: var(--background-color);
    border-radius: 12px;
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    word-break: break-all;
    font-family: 'Courier New', monospace;
    font-size: 1rem;
    line-height: 1.6;
    max-height: 300px;
    overflow-y: auto;
}

/* Quick Actions */
.quick-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.quick-action-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--border-radius);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

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

.open-url-btn:hover {
    background: #1d4ed8;
}

.save-contact-btn {
    background: var(--accent-color);
    color: white;
}

.save-contact-btn:hover {
    background: #047857;
}

.connect-wifi-btn {
    background: var(--warning-color);
    color: white;
}

.connect-wifi-btn:hover {
    background: #b45309;
}

/* History Section */
.history-section {
    background: var(--surface-color);
    border-radius: var(--border-radius);
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-light);
    border: 1px solid var(--border-color);
}

.history-section h3 {
    margin-bottom: 2rem;
    font-size: 1.5rem;
    color: var(--text-primary);
}

.history-list {
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 1rem;
}

.history-item {
    background: var(--background-color);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 0.5rem;
    border: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.history-info {
    flex: 1;
    min-width: 0;
}

.history-content {
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-meta {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.history-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.history-btn {
    padding: 0.25rem 0.75rem;
    border: none;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

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

.use-again-btn:hover {
    background: #1d4ed8;
}

.clear-history-btn {
    display: block;
    margin: 0 auto;
    padding: 0.5rem 1.5rem;
    background: var(--error-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.clear-history-btn:hover {
    background: #b91c1c;
}

/* Error Section */
.error-section {
    background: var(--surface-color);
    border-radius: var(--border-radius);
    padding: 3rem 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-light);
    border: 2px solid var(--error-color);
    text-align: center;
}

.error-content {
    max-width: 500px;
    margin: 0 auto;
}

.error-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.error-section h3 {
    color: var(--error-color);
    font-size: 1.8rem;
    margin-bottom: 1rem;
}

.error-section p {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-bottom: 2rem;
}

.error-suggestions {
    text-align: left;
    background: var(--background-color);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
}

.error-suggestions h4 {
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.error-suggestions ul {
    list-style: none;
    padding: 0;
}

.error-suggestions li {
    margin-bottom: 0.75rem;
    padding-left: 1.5rem;
    position: relative;
    color: var(--text-secondary);
}

.error-suggestions li::before {
    content: '💡';
    position: absolute;
    left: 0;
}

.primary-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.875rem 2rem;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.primary-btn:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
    box-shadow: var(--shadow-medium);
}

/* Tips Section */
.tips-section {
    background: var(--surface-color);
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--shadow-light);
    border: 1px solid var(--border-color);
}

.tips-section h3 {
    text-align: center;
    margin-bottom: 2rem;
    font-size: 1.5rem;
    color: var(--text-primary);
}

.tips-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.tip-item {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.tip-icon {
    font-size: 2rem;
    flex-shrink: 0;
}

.tip-content h4 {
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-size: 1rem;
}

.tip-content p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }

    header h1 {
        font-size: 2.5rem;
        flex-direction: column;
        gap: 0.5rem;
    }

    .method-tabs {
        flex-direction: column;
    }

    .method-tab {
        text-align: left;
    }

    .method-content {
        padding: 1.5rem;
    }

    .upload-area, .paste-area {
        padding: 2rem 1rem;
    }

    .upload-icon, .paste-icon {
        font-size: 3rem;
    }

    .camera-controls {
        flex-direction: column;
        align-items: center;
    }

    .camera-btn {
        width: 100%;
        max-width: 200px;
    }

    .scan-frame {
        width: 150px;
        height: 150px;
    }

    .result-header {
        flex-direction: column;
        align-items: stretch;
    }

    .result-actions {
        justify-content: center;
    }

    .quick-actions {
        flex-direction: column;
    }

    .history-item {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .history-actions {
        justify-content: center;
    }

    .tips-grid {
        grid-template-columns: 1fr;
    }

    .tip-item {
        flex-direction: column;
        text-align: center;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 2rem;
    }

    .processing-animation {
        width: 80px;
        height: 80px;
    }

    .scanner-line {
        width: 40px;
    }

    .results-section, .preview-section, .error-section {
        padding: 1.5rem;
    }

    .result-content {
        padding: 1rem;
        font-size: 0.9rem;
    }

    .scan-frame {
        width: 120px;
        height: 120px;
    }

    .error-icon {
        font-size: 3rem;
    }
}