/* Global styles for better box-model handling */
* {
    box-sizing: border-box;
}
/* Google Sans Font Definition (Restored from your original file) */
@font-face {
    font-family: 'Google Sans';
    src: url('fonts/GoogleSans-Bold.woff2') format('woff2'),
         url('fonts/GoogleSans-Bold.woff') format('woff');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Google Sans';
    src: url('fonts/GoogleSans-Medium.woff2') format('woff2'),
         url('fonts/GoogleSans-Medium.woff') format('woff');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Google Sans';
    src: url('fonts/GoogleSans-Regular.woff2') format('woff2'),
         url('fonts/GoogleSans-Regular.woff') format('woff');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

/* CSS Variables for Dark Mode */
:root {
    --background-color: #f0f2f5;
    --text-color: #333;
    --header-color: #0056b3;
    --column-bg: #fff;
    --column-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
    --border-color: #eee;
    --input-border: #ccd0d5;
    --input-focus-shadow: 0 0 0 4px rgba(0, 123, 255, 0.25);
    --button-bg: #007bff;
    --button-hover-bg: #0056b3;
    --button-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    --preview-border: #e0e0e0;
    --preview-shadow: 0 3px 8px rgba(0,0,0,0.08);
    --preview-domain-color: #666;
    --preview-title-color: #0056b3;
    --preview-description-color: #555;
    --google-url-color: #006621;
    --google-title-color: #1a0dab;
    --google-description-color: #545454;
    --info-section-bg: #e9f7ff;
    --info-section-border: #007bff;
    --info-text-color: #007bff;
    --placeholder-color: #999;
}

body.dark-mode {
    --background-color: #1a1a1a;
    --text-color: #e0e0e0;
    --header-color: #66b3ff;
    --column-bg: #2a2a2a;
    --column-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    --border-color: #444;
    --input-border: #555;
    --input-focus-shadow: 0 0 0 4px rgba(102, 179, 255, 0.3);
    --button-bg: #3399ff;
    --button-hover-bg: #007bff;
    --button-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    --preview-border: #444;
    --preview-shadow: 0 3px 8px rgba(0,0,0,0.2);
    --preview-domain-color: #bbb;
    --preview-title-color: #88c0ff;
    --preview-description-color: #ccc;
    --google-url-color: #90ee90;
    --google-title-color: #a0c0ff;
    --google-description-color: #ccc;
    --info-section-bg: #223344;
    --info-section-border: #3399ff;
    --info-text-color: #88c0ff;
    --placeholder-color: #777;
}

body {
    font-family: 'Google Sans', sans-serif;
    font-size: .94em;
    line-height: 1.6;
    margin: 0;
    padding: 0;
    background-color: var(--background-color);
    color: var(--text-color);
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    transition: background-color 0.3s ease, color 0.3s ease;
}
.header-title {
    text-align: center;
    color: var(--header-color);
    margin: 20px auto;
    padding: 0px 25px;
    border-radius: 10px;
    width: 98vw; /* Giữ lại cho desktop, responsive.css sẽ override */
    max-width: 1600px;
    box-sizing: border-box;
    font-size: 1.8em;
    flex-shrink: 0;
}

.main-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 25px;
    width: 98vw; /* Giữ lại cho desktop, responsive.css sẽ override */
    max-width: 1600px;
    padding: 0 0 20px 0;
    box-sizing: border-box;
    justify-content: center;
    align-items: flex-start;
    flex-grow: 1;
    min-height: 0;
}
.column {
    background: var(--column-bg);
    padding: 25px;
    border-radius: 10px;
    box-shadow: var(--column-shadow);
    flex: 1;
    min-width: unset; /* **Loại bỏ min-width cố định ở đây** */
    max-width: calc(50% - 17px);
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    
    max-height: calc(100vh - 126px);
    overflow-y: auto;
    padding-bottom: 20px;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

h2 {
    color: var(--header-color);
    text-align: center;
    margin-top: 0;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
    font-size: 1.3em;
    flex-shrink: 0;
    transition: color 0.3s ease, border-color 0.3s ease;
}

.input-section {
    text-align: center;
    flex-grow: 1;
    flex-shrink: 0;
}
.input-section label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    font-size: 1em;
    color: var(--text-color);
    text-align: left;
    transition: color 0.3s ease;
}
.input-section input[type="text"],
.input-section input[type="file"],
.input-section textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--input-border);
    border-radius: 6px;
    margin-bottom: 13px;
    font-size: 1em;
    box-sizing: border-box;
    transition: border-color 0.3s ease, box-shadow 0.3s ease, background-color 0.3s ease, color 0.3s ease;
    font-family: 'Google Sans', sans-serif;
    background-color: var(--column-bg);
    color: var(--text-color);
}
.input-section input[type="text"]:focus,
.input-section textarea:focus {
    border-color: var(--button-bg);
    outline: none;
    box-shadow: var(--input-focus-shadow);
}
.input-section textarea {
    resize: vertical;
    min-height: 120px;
    max-height: 250px;
}
.button-group {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 10px;
    margin-top: 10px;
    flex-shrink: 0;
    justify-content: center;
}
.button-group button {
    background-color: var(--button-bg);
    color: white;
    font-family: 'Google Sans', sans-serif;
    padding: 15px 22px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: .875em;
    transition: background-color 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: var(--button-shadow);
    white-space: nowrap;
}
.button-group button:hover {
    background-color: var(--button-hover-bg);
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
}
.button-group button i {
    font-size: 1.1em;
}

/* Character Counter Styles */
.char-count {
    font-size: 0.85em;
    color: #777;
    text-align: right;
    margin-top: -10px;
    margin-bottom: 10px;
    display: block;
    transition: color 0.3s ease;
}
.char-count.warning {
    color: orange;
}
.char-count.error {
    color: red;
    font-weight: bold;
}

/* Image dimension display */
.image-dimensions {
    font-size: 0.85em;
    color: #777;
    text-align: left;
    margin-top: -10px;
    margin-bottom: 10px;
    display: block;
    transition: color 0.3s ease;
}

/* Loading Indicator */
#loadingIndicator {
    display: none;
    margin-top: 15px;
    font-size: 1em;
    color: var(--header-color);
    font-weight: bold;
    transition: color 0.3s ease;
}

/* Dark Mode Toggle Button and Reset Button (now fixed) */
.dark-mode-toggle, .reset-button {
    background-color: var(--button-bg);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 15px;
    cursor: pointer;
    font-size: 0.9em;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    transition: background-color 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease;
    box-shadow: var(--button-shadow);
    justify-content: center;
    width: fit-content;
}
.dark-mode-toggle:hover, .reset-button:hover {
    background-color: var(--button-hover-bg);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}
.dark-mode-toggle i, .reset-button i {
    font-size: 1.2em;
}

/* New styles for fixed bottom right controls */
.fixed-bottom-controls {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column-reverse;
    align-items: flex-end;
    gap: 15px;
}


/* --- Share Preview Section Styles --- */
.preview-guidance {
    font-size: 0.9em;
    color: var(--info-text-color);
    background-color: var(--info-section-bg);
    border-left: 4px solid var(--info-section-border);
    padding: 10px 15px;
    border-radius: 4px;
    margin-top: -10px;
    flex-shrink: 0;
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}
.preview-guidance i {
    margin-right: 8px;
}

.preview-box {
    border: 1px solid var(--preview-border);
    border-radius: 10px;
    overflow: hidden;
    background-color: var(--column-bg);
    box-shadow: var(--preview-shadow);
    width: 100%; /* **Thay đổi từ 450px thành 100%** */
    max-width: 450px; /* **Thêm max-width để giới hạn trên desktop** */
    text-align: left;
    flex-shrink: 0;
    margin: 20px auto;
    transition: background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}
.preview-image {
    width: 100%;
    position: relative;
    padding-bottom: 52.35%;
    background-color: var(--border-color);
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background-color 0.3s ease;
}
.preview-image img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: none;
}
.preview-image .placeholder-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    width: 90%;
    color: var(--placeholder-color);
    transition: color 0.3s ease;
}
.preview-content {
    padding: 20px;
}
.preview-domain {
    font-size: 0.85em;
    color: var(--preview-domain-color);
    margin-bottom: 8px;
    text-transform: uppercase;
    transition: color 0.3s ease;
}
.preview-title {
    font-size: 1.15em;
    font-weight: bold;
    color: var(--preview-title-color);
    margin-bottom: 10px;
    transition: color 0.3s ease;
}
.preview-description {
    font-size: 0.95em;
    color: var(--preview-description-color);
    margin-bottom: 10px;
    transition: color 0.3s ease;
}
/* --- End Share Preview Section Styles --- */

/* --- Google Search Preview Styles --- */
.google-result-box {
    background-color: var(--column-bg);
    padding: 20px;
    border: 1px solid var(--preview-border);
    border-radius: 10px;
    max-width: 650px; /* Giữ nguyên max-width */
    width: 100%; /* Đảm bảo nó chiếm 100% chiều rộng của cha nó */
    margin: 20px auto;
    box-shadow: var(--preview-shadow);
    text-align: left;
    flex-shrink: 0;
    transition: background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}
.google-url-line {
    display: flex;
    align-items: center;
    margin-bottom: 6px;
}
.google-favicon-wrapper {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background-color: var(--border-color);
    display: flex;
    justify-content: center;
    align-items: center;
    margin-right: 10px;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,.08);
    flex-shrink: 0;
    overflow: hidden;
    transition: background-color 0.3s ease;
}
.google-favicon-wrapper img {
    width: 100%; 
    height: 100%;
    object-fit: cover;
}
.google-url {
    font-size: 0.9em;
    color: var(--google-url-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
    transition: color 0.3s ease;
}
.google-title {
    font-size: 1.3em;
    color: var(--google-title-color);
    text-decoration: none;
    margin-bottom: 6px;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
    transition: color 0.3s ease;
}
.google-description {
    font-size: 0.95em;
    color: var(--google-description-color);
    line-height: 1.6;
    word-wrap: break-word;
    transition: color 0.3s ease;
}
/* --- End Google Search Preview Styles --- */

.info-section {
    margin-top: 30px;
    padding: 20px;
    background-color: var(--info-section-bg);
    border-left: 6px solid var(--info-section-border);
    border-radius: 6px;
    font-size: 0.95em;
    text-align: left;
    flex-grow: 1;
    display: flex;
    align-items: center;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}
.info-section p {
    margin: 0;
}
.info-section a {
    color: var(--info-text-color);
    text-decoration: none;
}
.info-section a:hover {
    text-decoration: underline;
}

/* Footer Copyright */
.footer-copyright {
    text-align: center;
    margin-top: 20px;
    padding-bottom: 10px;
    font-size: 0.85em;
    color: #777;
    width: 100%;
    flex-shrink: 0;
    transition: color 0.3s ease;
}
.footer-copyright a {
    color: var(--text-color);
    text-decoration: none;
    transition: color 0.3s ease;
}
.footer-copyright a:hover {
    text-decoration: underline;
    color: var(--header-color);
}
body.dark-mode .footer-copyright {
    color: #bbb;
}

html, body {
    overflow-x: hidden;
}