/* --- Google Font Import --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap');

/* --- CSS Variables --- */
:root {
    --primary-color: #17a2b8;
    --primary-hover: #138496;
    --secondary-color: #6c757d;
    --light-bg: #f0f8ff;
    --white-color: #ffffff;
    --dark-bg: #212529;
    --medium-dark-bg: #343a40;
    --light-text-on-dark: #f8f9fa;
    --dark-text-on-light: #212529;
    --border-color: #495057;
    --light-border-color: #dee2e6;
    --success-color: #28a745;
    --success-bg: #d4edda;
    --success-border: #c3e6cb;
    --success-text: #155724;
    --error-color: #dc3545;
    --error-bg: #f8d7da;
    --error-border: #f5c6cb;
    --error-text: #721c24;
    --info-color: #17a2b8;
    --info-bg: #e2f6f9;
    --info-border: #b8e5ec;
    --info-text: #0c5464;
    --border-radius: 6px;
    --box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    --box-shadow-hover: 0 8px 20px rgba(0, 0, 0, 0.12);
    --box-shadow-dark: 0 4px 15px rgba(0, 0, 0, 0.3);
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --chat-user-bg: var(--primary-color);
    --chat-user-text: var(--white-color);
    --chat-ai-bg: #e9ecef;
    --chat-ai-text: var(--dark-text-on-light);
    --chat-input-bg: var(--white-color);
    --chat-messages-bg: #f9f9f9;
}

/* --- General Styles --- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { font-family: var(--font-family); margin: 0; padding: 0; background-color: var(--light-bg); color: var(--dark-text-on-light); line-height: 1.65; font-size: 16px; }
.container { max-width: 960px; margin: 0 auto; padding: 0 20px; }
h1, h2, h3, h4 { color: var(--primary-color); margin-top: 0; margin-bottom: 0.75em; font-weight: 600; }
h1 { font-size: 2.4em; font-weight: 700; margin-bottom: 0.25em;}
h2 { font-size: 1.8em; padding-bottom: 0.3em; border-bottom: 3px solid var(--primary-color); display: inline-block; }
h3 { font-size: 1.4em; color: var(--secondary-color); }
h4 { font-size: 1.15em; color: var(--dark-text-on-light); margin-top: 1.5em; font-weight: 600; }
a { color: var(--primary-color); text-decoration: none; transition: color 0.2s ease; }
a:hover { color: var(--primary-hover); text-decoration: underline; }
p { margin-bottom: 1em; }
p:last-child { margin-bottom: 0; }
i, .fa, .fas, .fab, .far, .fa-solid { margin-right: 0.5em; vertical-align: middle; }
button i { margin-right: 0.6em;}
pre { border: 1px solid var(--light-border-color); padding: 18px; border-radius: var(--border-radius); background-color: #e9ecef; color: var(--dark-text-on-light); margin-top: 1em; white-space: pre-wrap; word-wrap: break-word; font-family: 'Consolas', 'Monaco', 'Courier New', monospace; font-size: 0.95em; max-height: 450px; overflow-y: auto; line-height: 1.5; }

/* --- Header --- */
header { background: linear-gradient(90deg, var(--primary-color) 0%, var(--primary-hover) 100%); color: var(--white-color); padding: 25px 0; margin-bottom: 40px; box-shadow: 0 3px 8px rgba(0,0,0,0.15); }
.header-content { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; }
.header-content h1 { color: var(--white-color); margin: 0; display: flex; align-items: center; }
.header-content h1 a { color: var(--white-color); text-decoration: none; }
.subtitle { margin: 5px 0 0 0; font-size: 1em; opacity: 0.9; flex-basis: 100%;}
.main-nav { margin-left: auto; }
.nav-link { color: var(--white-color); text-decoration: none; padding: 8px 15px; border-radius: var(--border-radius); transition: background-color 0.2s ease; font-weight: 500; display: inline-flex; align-items: center; }
.nav-link:hover { background-color: rgba(255, 255, 255, 0.2); text-decoration: none; }
.nav-link i { margin-right: 0.4em; }

/* --- Main Content & Cards --- */
.main-content { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 400px), 1fr)); gap: 35px; margin-top: 20px; margin-bottom: 40px; }
.main-content-view, .main-content-chat { margin-top: 20px; margin-bottom: 40px; }
.card { background-color: var(--white-color); border-radius: var(--border-radius); box-shadow: var(--box-shadow); padding: 35px; border: 1px solid var(--light-border-color); transition: transform 0.2s ease-out, box-shadow 0.2s ease-out; display: flex; flex-direction: column; }
.card:hover { transform: translateY(-4px); box-shadow: var(--box-shadow-hover); }

/* --- Forms & Inputs --- */
textarea, input[type="text"], input[type="password"] { width: 100%; padding: 14px; border-radius: 5px; border: 1px solid var(--light-border-color); margin-bottom: 18px; font-size: 1em; transition: border-color 0.2s ease, box-shadow 0.2s ease; background-color: #fdfdff; color: var(--dark-text-on-light); line-height: 1.5; }
textarea:focus, input[type="text"]:focus, input[type="password"]:focus { border-color: var(--primary-color); box-shadow: 0 0 0 3px rgba(23, 162, 184, 0.25); outline: none; }
textarea { resize: vertical; min-height: 100px; }
.radio-options { margin-bottom: 18px; display: flex; flex-wrap: wrap; gap: 15px 25px; }
.radio-options label { cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font-size: 1em; }
input[type="radio"] { accent-color: var(--primary-color); width: 1.1em; height: 1.1em; }

/* --- Buttons --- */
button, .back-link-button { display: inline-flex; align-items: center; justify-content: center; gap: 0.6em; background-color: var(--primary-color); color: white; border: none; border-radius: 5px; padding: 14px 25px; cursor: pointer; font-size: 1.05em; font-weight: 600; text-align: center; transition: background-color 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease; margin-top: 10px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); text-decoration: none; }
button:hover, .back-link-button:hover { background-color: var(--primary-hover); transform: translateY(-2px); box-shadow: 0 4px 8px rgba(0,0,0,0.15); }
button:active, .back-link-button:active { transform: translateY(0px); box-shadow: 0 1px 2px rgba(0,0,0,0.1); }
button:disabled { background-color: var(--secondary-color); cursor: not-allowed; opacity: 0.6; transform: none; box-shadow: none; }
.copy-btn { background-color: var(--secondary-color); padding: 12px 20px; font-size: 1em; }
.copy-btn:hover { background-color: #5a6268; }
.copy-btn-small { padding: 8px 14px; font-size: 0.9em; background-color: var(--success-color); margin-left: 10px; }
.copy-btn-small:hover { background-color: #218838; }

/* --- Feedback & Messages --- */
.feedback { margin-top: 15px; padding: 12px 15px; border-radius: 5px; font-size: 0.95em; display: none; border: 1px solid transparent; line-height: 1.4; }
.feedback.success { background-color: var(--success-bg); color: var(--success-text); border-color: var(--success-border); display: block; }
.feedback.error { background-color: var(--error-bg); color: var(--error-text); border-color: var(--error-border); display: block; }
.feedback.info { background-color: var(--info-bg); color: var(--info-text); border-color: var(--info-border); display: block; }
.suggestions { margin-top: 12px; font-size: 0.9em; color: var(--secondary-color); padding: 10px 5px; }
.suggestions span { cursor: pointer; color: var(--primary-color); margin-right: 12px; display: inline-block; padding: 3px 6px; border-radius: 4px; background-color: var(--info-bg); border: 1px solid var(--info-border); transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease; }
.suggestions span:hover { background-color: var(--primary-color); color: var(--white-color); border-color: var(--primary-hover); }
.suggestions span:last-child { margin-right: 0; }

/* --- Retrieved Text & Links & QR --- */
#retrievedContent h3, .view-section h2 { margin-bottom: 15px; border-bottom: none; display: block; }
.link-display, .link-display-retrieved { margin-top: 18px; padding: 12px 15px; background-color: var(--info-bg); border: 1px solid var(--info-border); border-radius: var(--border-radius); font-size: 1em; word-break: break-all; color: var(--info-text); }
.link-display a, .link-display-retrieved a { color: var(--primary-hover); font-weight: bold; }
.link-display a:hover, .link-display-retrieved a:hover { color: var(--primary-color); }
.link-qr-container { margin-top: 25px; padding-top: 20px; border-top: 1px dashed var(--light-border-color); }
.qr-and-copy { display: flex; align-items: center; margin-top: 15px; gap: 15px; flex-wrap: wrap;}
.qr-code { display: inline-block; }
.qr-code img { border: 1px solid var(--light-border-color); padding: 6px; background-color: var(--white-color); display: block; }

/* --- Edit Section --- */
.edit-subsection { margin-top: 30px; padding-top: 25px; border-top: 1px dashed var(--light-border-color); }
.edit-subsection .requires-pass { font-size: 0.85em; color: var(--secondary-color); font-weight: normal; }

/* --- Guide Section --- */
.guide-section { background-color: var(--info-bg); border-left: 5px solid var(--primary-color); color: var(--dark-text-on-light); margin-top: 20px; }
.guide-section h2 { color: var(--primary-color); border-bottom: none; }
.guide-section ol { padding-left: 25px; margin-bottom: 0; list-style-type: decimal; }
.guide-section li { margin-bottom: 10px; padding-left: 5px; }

/* --- Blog Section --- */
.blog-section { margin-top: 40px; padding-top: 25px; border-top: 1px solid var(--light-border-color); }
.blog-section h2 { text-align: center; border-bottom: none; margin-bottom: 30px; }
.blog-post { background-color: var(--white-color); padding: 20px; border-radius: var(--border-radius); margin-bottom: 20px; box-shadow: 0 2px 5px rgba(0,0,0,0.06); border: 1px solid var(--light-border-color); }
.blog-post h3 { color: var(--primary-color); font-size: 1.2em; margin-bottom: 8px; }
.blog-post p { margin-bottom: 10px; font-size: 1em; }
.blog-post p:last-child { margin-bottom: 0; }
.blog-post em { color: var(--secondary-color); font-size: 0.9em; }

/* --- View Page Specific --- */
.view-section { padding: 40px; }
.view-section h2 { text-align: center; margin-bottom: 25px; }
.expiry-info { text-align: center; margin-top: 25px; margin-bottom: 20px; font-size: 0.95em; color: var(--secondary-color); }
.expiry-info.expired { color: var(--error-color); font-weight: bold; }
.view-buttons { margin-top: 25px; display: flex; justify-content: center; gap: 15px; flex-wrap: wrap; }

/* --- Footer --- */
footer { margin-top: 60px; padding: 30px 0; background-color: var(--medium-dark-bg); color: var(--light-text-on-dark); text-align: center; font-size: 0.95em; }
footer p { margin: 0; opacity: 0.8; }
footer a { color: var(--primary-color); }
footer a:hover { color: var(--primary-hover); }

/* --- AI Chat Page Styles --- */
.chat-container-wrapper { max-width: 800px; margin: 0 auto; }
.chat-card { display: flex; flex-direction: column; height: 70vh; min-height: 500px; padding: 25px; }
.chat-settings-area { margin-bottom: 15px; padding-bottom: 15px; border-bottom: 1px solid var(--light-border-color); }
.chat-settings-area details { border: 1px solid var(--light-border-color); border-radius: var(--border-radius); padding: 10px; background-color: #fdfdfd; }
.chat-settings-area summary { font-weight: 600; cursor: pointer; color: var(--primary-color); padding: 5px; }
.chat-settings-area summary:hover { color: var(--primary-hover); }
.chat-settings-area summary i { margin-right: 8px; }
.settings-fields { padding-top: 15px; }
.setting-field { margin-bottom: 15px; }
.setting-field label { display: block; font-weight: 500; margin-bottom: 6px; font-size: 0.9em; color: var(--dark-text-on-light); }
.setting-field label i { margin-right: 6px; color: var(--secondary-color); }
.setting-field input[type="password"], .setting-field textarea { width: 100%; padding: 10px; font-size: 0.95em; margin-bottom: 5px; }
.setting-field textarea { min-height: 60px; resize: vertical; line-height: 1.4; }
.setting-field small { font-size: 0.8em; color: var(--secondary-color); display: block; }
#saveSettingsButton { font-size: 0.95em; padding: 10px 18px; margin-top: 5px; background-color: var(--success-color); }
#saveSettingsButton:hover { background-color: #218838; }
.feedback-inline { font-size: 0.9em; margin-left: 10px; }
.feedback-inline.success { color: var(--success-text); }
.feedback-inline.error { color: var(--error-text); }
.chat-controls { display: flex; justify-content: flex-end; margin-bottom: 10px; }
.chat-controls button { background-color: var(--secondary-color); font-size: 0.9em; padding: 8px 15px; margin-top: 0; }
.chat-controls button:hover { background-color: #5a6268; }
.chat-messages { flex-grow: 1; overflow-y: auto; padding: 10px; border: 1px solid var(--light-border-color); border-radius: var(--border-radius); margin-bottom: 20px; background-color: var(--chat-messages-bg); }
.chat-message { padding: 10px 15px; border-radius: var(--border-radius); margin-bottom: 12px; max-width: 85%; line-height: 1.5; word-wrap: break-word; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
.chat-message.user { background-color: var(--chat-user-bg); color: var(--chat-user-text); margin-left: auto; text-align: left; border-bottom-right-radius: 3px; }
.chat-message.ai { background-color: var(--chat-ai-bg); color: var(--chat-ai-text); margin-right: auto; text-align: left; border-bottom-left-radius: 3px; }
.chat-message.error { background-color: var(--error-bg); color: var(--error-text); border: 1px solid var(--error-border); text-align: center; max-width: 100%; }
.chat-message strong { display: block; font-size: 0.8em; margin-bottom: 4px; opacity: 0.8; }
.ai-content-wrapper { margin-top: 5px; }
.ai-content-wrapper p:first-child { margin-top: 0; }
.ai-content-wrapper p:last-child { margin-bottom: 0; }
.code-block-wrapper { position: relative; margin: 0.8em 0; }
.copy-code-button { position: absolute; top: 6px; right: 6px; padding: 5px 10px; font-size: 0.8em; background-color: var(--secondary-color); color: var(--white-color); border: none; border-radius: 4px; cursor: pointer; opacity: 0; transition: opacity 0.2s ease-in-out, background-color 0.2s ease-in-out; z-index: 1; }
.code-block-wrapper:hover .copy-code-button { opacity: 0.8; }
.copy-code-button:hover { opacity: 1; background-color: var(--primary-color); }
.copy-code-button:disabled { background-color: var(--success-color); opacity: 1; cursor: default; }
.copy-code-button i { margin-right: 4px; }
.ai-content-wrapper .code-block-wrapper pre { margin: 0; padding: 0.8em 1em; border-radius: 4px; overflow-x: auto; font-family: 'Consolas', 'Monaco', 'Courier New', monospace; font-size: 0.9em; line-height: 1.45; }
.ai-content-wrapper .code-block-wrapper pre code[class*="language-"] { font-size: inherit !important; background: none !important; text-shadow: none !important; }
.ai-content-wrapper code:not([class*="language-"]) { background-color: rgba(0,0,0,0.06); padding: 0.2em 0.4em; border-radius: 3px; font-size: 0.9em; }
.chat-input-area { display: flex; gap: 10px; align-items: flex-end; }
.chat-input-area textarea { flex-grow: 1; margin-bottom: 0; min-height: 50px; max-height: 150px; resize: none; line-height: 1.5; padding: 12px; border-radius: var(--border-radius); }
.chat-input-area button { margin-top: 0; padding: 0 20px; height: 50px; flex-shrink: 0; border-radius: var(--border-radius); }

/* --- Responsive Adjustments --- */
@media (max-width: 992px) { .container { max-width: 800px; } }
@media (max-width: 768px) { h1 { font-size: 2em; } h2 { font-size: 1.6em; } .main-content { grid-template-columns: 1fr; gap: 30px; } .card { padding: 25px; } .guide-section { margin-top: 30px; } footer { margin-top: 40px; padding: 25px 0;} .header-content { flex-direction: column; align-items: flex-start; } .main-nav { margin-left: 0; margin-top: 10px; } .chat-card { height: auto; min-height: 400px; padding: 20px; } }
@media (max-width: 480px) { body { font-size: 15px; } .container { padding: 0 15px; } h1 { font-size: 1.8em; } h2 { font-size: 1.4em; } .card { padding: 20px; } button, .back-link-button { width: 100%; padding: 12px 15px; font-size: 1em;} .copy-btn, .copy-btn-small { width: auto; } .radio-options { flex-direction: column; gap: 15px; align-items: flex-start; } textarea, input[type="text"], input[type="password"] { padding: 12px; } .qr-and-copy { flex-direction: column; align-items: flex-start; } .copy-btn-small { margin-left: 0; margin-top: 10px; } .view-buttons { flex-direction: column; } .chat-input-area { flex-direction: column; align-items: stretch; } .chat-input-area textarea { width: 100%; } .chat-input-area button { width: 100%; margin-top: 10px; height: auto; padding: 12px 15px;} }
