:root {
    --primary-color: #0a68ff; /* Example primary color */
    --border-color: #ccc;
    --background-color: #f9f9f9;
    --text-color: #333;
    --error-color: #d9534f;
    --success-color: #5cb85c;
    --link-color: var(--primary-color);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    margin: 0;
    color: var(--text-color);
    background-color: #fff;
}

header {
    background-color: var(--primary-color);
    color: white;
    padding: 1em 2em;
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    box-sizing: border-box; /* Include padding in width */
}

header .logo {
    display: flex;
    align-items: center;
}

header .logo img {
    height: 40px;
    width: auto;
}

header nav a {
    color: white;
    text-decoration: none;
    margin-left: 1em;
}

main {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2em;
    width: 100%;
    max-width: 1000px; /* Increased width to accommodate 4 feature cards in one row */
    margin: 0 auto; /* Center content */
    box-sizing: border-box;
}

.hero {
    text-align: center;
    margin-bottom: 2em;
}

.hero h1 {
    font-size: 2.5em;
    margin-bottom: 0.2em;
    color: var(--primary-color);
}

.hero p {
    color: #555;
    font-size: 1.1em;
}

.raycast-news {
    width: 100%;
    box-sizing: border-box;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 24px;
    align-items: center;
    margin: 0 0 1.5em 0;
    padding: 22px 24px;
    border: 1px solid #dbe8ff;
    border-radius: 8px;
    background: #f4f8ff;
}

.raycast-news-label {
    display: inline-block;
    margin-bottom: 8px;
    color: #0a68ff;
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.raycast-news h2 {
    margin: 0 0 8px 0;
    color: #14345f;
    font-size: 1.35rem;
    line-height: 1.25;
}

.raycast-news p {
    margin: 0;
    color: #40546f;
    line-height: 1.6;
}

.raycast-news-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    min-width: 210px;
}

.raycast-news-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    box-sizing: border-box;
    padding: 11px 16px;
    border-radius: 6px;
    background: #0a68ff;
    color: white;
    text-decoration: none;
    font-weight: 700;
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.raycast-news-button:hover {
    background: #0056d3;
    transform: translateY(-1px);
}

.raycast-news-link {
    color: #0a68ff;
    font-weight: 600;
    text-decoration: none;
}

.raycast-news-link:hover {
    text-decoration: underline;
}

.upload-area {
    border: 3px dashed var(--border-color);
    padding: 2em;
    text-align: center;
    margin-top: 1em;
    background-color: var(--background-color);
    border-radius: 8px;
    width: 100%;
    transition: background-color 0.2s ease, border-color 0.2s ease;
    position: relative; /* Needed for overlay or absolute positioning inside */
}

.upload-area.dragover {
    border-color: var(--primary-color);
    background-color: #e7f0ff; /* Light blue background on drag over */
}

.upload-area p {
    margin-bottom: 1em;
    color: #666;
    font-size: 1.1em;
    pointer-events: none; /* Allow clicks to pass through to dropZone */
}

#uploadForm input[type="file"] {
    display: none; /* Hide default input, use label */
}

#uploadForm label {
    background-color: var(--primary-color);
    color: white;
    padding: 0.8em 1.5em;
    border-radius: 5px;
    cursor: pointer;
    display: inline-block;
    /* margin-right: 1em; */ /* Removed as button is removed */
    transition: background-color 0.2s ease;
}

#uploadForm label:hover {
    background-color: #0056d3; /* Darker blue on hover */
}

/* Remove submit button if auto-uploading */
/* #uploadForm button { ... } */

#progress {
    margin-top: 1em;
    color: var(--primary-color);
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* Loading spinner animation */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(10, 104, 255, 0.3);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

pre { /* Apply base wrapping to all pre tags */
    white-space: pre-wrap;   /* Preserve formatting but wrap lines */
    word-wrap: break-word;   /* Break long words nicely */
    /* word-break: break-all; */ /* Use if break-word isn't enough */
    overflow-x: auto;      /* Add scrollbar if needed */
    margin: 0.5em 0;       /* Add some default margin */
}

#result pre,
#error pre, 
#fileNameDisplay pre {
    /* Reset base margin if needed by specific containers */
    margin-top: 0;
    margin-bottom: 0;
}

#result, #error, #fileNameDisplay {
    margin-top: 1.5em;
    padding: 1em;
    border: 1px solid var(--border-color);
    background-color: white;
    border-radius: 5px;
    /* white-space: pre-wrap; -> Move to pre tag */
    word-break: break-all; /* Keep this on container for safety? Maybe not needed. */
    text-align: left;
    width: 100%;
    box-sizing: border-box;
}

#error {
    color: var(--error-color);
    border-color: var(--error-color);
    background-color: #fdd;
}

#fileNameDisplay {
    background-color: #eef;
    border-color: #dde;
    color: #337;
}
#fileNameDisplay span {
    font-weight: bold;
}

/* Link container styles */
.link-container {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    position: relative;
}

.non-clickable-link {
    color: var(--link-color);
    text-decoration: none;
    cursor: text; /* 改为文本光标，表示不可点击 */
    user-select: all; /* 允许选择文本 */
}

.non-clickable-link:hover {
    text-decoration: none; /* 移除悬停下划线 */
}

.copy-btn {
    background: none;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 2px 6px;
    cursor: pointer;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    transition: all 0.2s ease;
    background-color: #f8f9fa;
    margin-left: 4px;
}

.copy-btn:hover {
    background-color: #e9ecef;
    border-color: #adb5bd;
    transform: scale(1.05);
}

.copy-btn:active {
    transform: scale(0.95);
}

/* 保留原有的链接样式作为后备 */
#result a:not(.non-clickable-link) {
    color: var(--link-color);
    text-decoration: none;
}

#result a:not(.non-clickable-link):hover {
    text-decoration: underline;
}

#result code { /* Styles for the code *inside* the result pre */
    font-family: monospace;
    display: block; /* Keep block display */
    /* No wrap styles needed here if pre handles it */
}

.usage {
    margin-top: 3em;
    padding: 1.5em;
    background-color: var(--background-color);
    border: 1px solid #eee;
    border-radius: 8px;
    width: 100%;
}

.usage h2 {
    margin-top: 0;
    color: var(--primary-color);
    border-bottom: 1px solid #eee;
    padding-bottom: 0.5em;
    margin-bottom: 1em;
}

.usage h3 {
    margin-top: 1.5em;
    margin-bottom: 0.5em;
}

.usage h4 {
    margin-top: 1em;
    margin-bottom: 0.3em;
    color: #444;
}

.usage code { /* Style inline code snippets */
    background-color: #e3e3e3;
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-family: monospace;
    word-break: break-word; /* Allow break for inline code too */
}

.usage pre { /* Style the pre block itself */
    background-color: #2d2d2d;
    color: #ccc;
    padding: 1em;
    border-radius: 5px;
    /* Inherits wrapping from base 'pre' rule */
}

.usage pre code { /* Style code inside the pre block */
    background-color: transparent;
    padding: 0;
    border-radius: 0;
    /* white-space: pre-wrap; -> Move to pre */
    /* overflow-wrap: break-word; -> Move to pre */
    display: block; /* Keep block display */
}

footer {
    text-align: center;
    padding: 1.5em;
    margin-top: 2em;
    color: #777;
    background-color: #f1f1f1;
    width: 100%;
    box-sizing: border-box;
    border-top: 1px solid #ddd;
}

.hidden {
    display: none !important; /* Use important to ensure visibility toggle */
}

/* Feature Grid Styles */
.features {
    margin-top: 20px;
}

.feature-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr); /* Default: 4 columns in one row */
    gap: 15px;
    margin-top: 15px;
}

.features .feature-item {
    text-align: center;
    padding: 15px;
    background: rgba(10, 104, 255, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(10, 104, 255, 0.1);
}

.features .feature-item h3 {
    margin: 0 0 10px 0;
    color: var(--primary-color);
    font-size: 1.1em;
}

.features .feature-item p {
    margin: 0;
    font-size: 0.9em;
    color: #666;
}

/* FAQ Styles */
.faq .faq-item {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
}

.faq .faq-item h3 {
    margin: 0 0 10px 0;
    color: var(--primary-color);
    font-size: 1.1em;
}

.faq .faq-item p {
    margin: 0;
    line-height: 1.6;
    color: #555;
}

/* Upload buttons container */
.upload-buttons {
    display: flex;
    gap: 1em;
    align-items: center;
    justify-content: center;
    margin-bottom: 1em;
}

/* QR Code button in header */
.qrcode-btn-header {
    background-color: #6c757d;
    color: white;
    border: none;
    padding: 0.8em 1.2em;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.2s ease;
}

.qrcode-btn-header:enabled {
    background-color: var(--primary-color);
}

.qrcode-btn-header:enabled:hover {
    background-color: #0056d3;
}

.qrcode-btn-header:disabled {
    background-color: #6c757d;
    cursor: not-allowed;
    opacity: 0.6;
}

/* Modal styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background-color: white;
    padding: 2em;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    text-align: center;
    max-width: 90vw;
    max-height: 90vh;
    overflow: auto;
}

.modal-content h4 {
    margin: 0 0 1.5em 0;
    color: var(--primary-color);
    font-size: 1.3em;
}

.modal-content canvas {
    border: 2px solid #e9ecef;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    margin-bottom: 1em;
}

.qrcode-url {
    font-family: monospace;
    font-size: 0.85em;
    color: #666;
    word-break: break-all;
    background-color: #f1f3f4;
    padding: 0.8em;
    border-radius: 6px;
    margin: 0;
    max-width: 350px;
    line-height: 1.4;
    border: 1px solid #e0e0e0;
}

/* Copy message styles */
.copy-message {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    border-radius: 6px;
    padding: 0.8em 1em;
    margin-top: 1em;
    text-align: center;
    font-size: 0.9em;
    font-weight: 500;
    transition: all 0.3s ease;
    opacity: 0;
    transform: translateY(-10px);
}

.copy-message.show {
    opacity: 1;
    transform: translateY(0);
}

.copy-message.hidden {
    display: none;
}

/* Responsive Design Improvements */

/* Medium screens (tablets): 2x2 layout */
@media (max-width: 992px) and (min-width: 769px) {
    .feature-grid {
        grid-template-columns: repeat(2, 1fr); /* 2x2 layout */
    }
}

/* Small screens (mobile): 1x4 layout */
@media (max-width: 768px) {
    .raycast-news {
        grid-template-columns: 1fr;
        gap: 16px;
        padding: 18px;
    }

    .raycast-news-actions {
        align-items: stretch;
        min-width: 0;
    }

    .feature-grid {
        grid-template-columns: 1fr; /* 1x4 layout */
        gap: 10px;
    }
    
    footer > div > div {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }
    
    .faq {
        margin: 20px auto !important;
        padding: 0 10px !important;
    }
    
    main {
        padding: 1em; /* Reduce padding on mobile */
    }
}

/* Google Ads Container - Hidden until real ads are integrated */
.google-ad-container {
    display: none; /* Remove this line when real ads are ready */
    margin: 2em 0;
    max-width: 728px; /* Standard leaderboard ad size */
    border: 1px solid #e8f0fe;
    border-radius: 8px;
    background-color: #ffffff;
    font-family: arial, sans-serif;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.google-ad-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 8px 4px 8px;
    background-color: #f8f9fa;
    border-bottom: 1px solid #e8eaed;
    font-size: 11px;
}

.ad-label {
    color: #5f6368;
    font-weight: 400;
    font-size: 11px;
    line-height: 16px;
}

.ad-choices {
    color: #1a73e8;
    text-decoration: none;
    cursor: pointer;
    font-size: 11px;
}

.ad-choices:hover {
    text-decoration: underline;
}

.google-ad-content {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    gap: 12px;
    min-height: 60px;
}

.ad-image {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background-color: #f1f3f4;
    border-radius: 4px;
}

.dropbox-logo {
    font-size: 24px;
    line-height: 1;
}

.baidu-logo {
    font-size: 24px;
    line-height: 1;
}

.ad-text {
    flex-grow: 1;
    min-width: 0;
}

.ad-title {
    margin: 0 0 4px 0;
    font-size: 18px;
    font-weight: 400;
    line-height: 22px;
    color: #1a73e8;
    cursor: pointer;
    text-decoration: none;
}

.ad-title:hover {
    text-decoration: underline;
}

.ad-description {
    margin: 0 0 4px 0;
    font-size: 14px;
    line-height: 20px;
    color: #3c4043;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ad-url {
    margin: 0;
    font-size: 14px;
    line-height: 20px;
    color: #1e8e3e;
    font-weight: 400;
}

.ad-cta {
    flex-shrink: 0;
    margin-left: 12px;
}

.ad-button {
    background-color: #1a73e8;
    color: white;
    border: 1px solid #1a73e8;
    border-radius: 4px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: background-color 0.2s ease;
    min-width: 80px;
}

.ad-button:hover {
    background-color: #1557b0;
    border-color: #1557b0;
}

.ad-button:active {
    background-color: #0d47a1;
    border-color: #0d47a1;
}

/* Mobile responsive for Google Ads */
@media (max-width: 768px) {
    .google-ad-container {
        margin: 1.5em 0;
        max-width: 100%;
    }

    .google-ad-content {
        padding: 8px 12px;
        gap: 8px;
        flex-direction: column;
        text-align: center;
    }

    .ad-image {
        width: 40px;
        height: 40px;
    }

    .ad-text {
        text-align: center;
    }

    .ad-cta {
        margin-left: 0;
        margin-top: 8px;
    }

    .ad-button {
        width: 100%;
        max-width: 200px;
    }
}
