/* Unified magazine theme for editriceartistica.it - elegant, warm, typographic */
:root {
    /* Primary palette */
    --primary-color: #1b2c4a;    /* deep burgundy */
    --primary-hover: #172b4e;
    --accent-color: #b08936;     /* gold accent */

    /* Neutrals and background like warm paper */
    --background-color: #fbf5ee; /* warm paper */
    --header-bg: rgba(255,255,255,0.95);
    --sidebar-bg: #ffffff;
    --border-color: #e9e1d6;

    /* Message/article tones */
    --article-bg: #fffdf9;
    --aside-bg: #fbf8f3;

    --text-primary: #222222;
    --text-secondary: #64615b;

    --font-heading: 'Playfair Display', Georgia, 'Times New Roman', serif;
    --font-body: 'Source Sans Pro', 'Inter', Arial, sans-serif;

    --shadow-sm: 0 2px 6px rgba(0,0,0,0.06);
    --shadow-md: 0 8px 30px rgba(0,0,0,0.08);

    --header-height: 65px;
    --input-bar-height: 88px;
}

/* Base */
html, body {
    height: 100%;
    margin: 0;
    font-family: var(--font-body);
    background-color: var(--background-color);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    max-width: 100vw;
    overflow-x: hidden;
}

body::-webkit-scrollbar {
  display: none;
}

/* Header - refined and centered brand */
.page-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--header-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-primary);
    letter-spacing: 0.6px;
}

.brand-logo { height: 100px; width: auto; object-fit: contain; max-width: 220px;}
.clink-logo  { height: 50px; width: auto; object-fit: contain; max-width: 220px;}
/* Layout */
.main-wrapper { display: flex; height: 100vh; padding-top: var(--header-height); box-sizing: border-box; }

.sidebar { width: 320px; flex-shrink: 0; background: var(--sidebar-bg); border-right: 1px solid var(--border-color); display: flex; flex-direction: column; height: 100%; }
.sidebar-content { padding: 1.25rem; overflow-y: auto; flex-grow: 1; }
.section-title { font-size: 0.8rem; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 1rem; font-family: var(--font-heading); }

/* Thumbnails and history */
.img-thumb { width: 100%; height: 64px; object-fit: cover; border-radius: 6px; border: 2px solid transparent; cursor: pointer; transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease; box-shadow: var(--shadow-sm); }
.img-thumb:hover, .img-thumb.selected { transform: translateY(-3px); border-color: var(--primary-color); box-shadow: var(--shadow-md); }
.history-list .list-group-item { border: 0; border-radius: 6px; padding: 0.6rem 1rem; margin-bottom: 0.4rem; font-size: 0.95rem; cursor: pointer; color: var(--text-primary); }
.history-list .list-group-item:hover { background: var(--aside-bg); color: var(--primary-color); }
.history-list .list-group-item.active { background: var(--primary-color); color: #fff; }

/* Main chat/article area */
.main-chat-area { flex-grow: 1; display: flex; flex-direction: column; height: 100%; box-sizing: border-box; }
.chat-area { flex-grow: 1; overflow-y: auto; padding: 2.25rem; display: flex; flex-direction: column; gap: 1.5rem; width: 100%; }

/* Input bar */
.input-bar-container { padding: 1rem 2rem; background: var(--background-color); border-top: 1px solid var(--border-color); transition: left 0.25s ease-in-out; }
.input-bar { display: flex; align-items: center; gap: 0.75rem; background-color: #ffffff; border-radius: 12px; padding: 0.6rem; box-shadow: var(--shadow-sm); border: 1px solid var(--border-color); }
.input-bar textarea { flex-grow: 1; border: none; outline: none; resize: none; padding: 0.5rem; background: transparent; font-size: 1rem; max-height: 160px; font-family: var(--font-body); }
.btn-icon { background: transparent; border: none; color: var(--text-secondary); padding: 0.5rem; border-radius: 8px; display: flex; align-items: center; justify-content: center; transition: all 0.18s ease; }
.btn-icon:hover { background: var(--aside-bg); color: var(--text-primary); }
.btn-icon.btn-send { background: var(--primary-color); color: white; border-radius: 10px; padding: 0.6rem 0.9rem; }
.btn-icon.btn-send:hover { background: var(--primary-hover); }

/* Make the primary action button match the send button styling */
.btn-primary, .btn-primary:active, .btn-primary:focus {
    background-color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
    color: #ffffff !important;
    font-weight: 600;
    padding: 0.55rem 0.9rem;
    border-radius: 10px;
    box-shadow: none;
}
.btn-primary:hover {
    background-color: var(--primary-hover) !important;
    border-color: var(--primary-hover) !important;
}

/* Messages / Articles */
.msg-row { display: flex; align-items: flex-start; gap: 1rem; max-width: 75%; }
.msg-row.user { align-self: flex-end; }
.msg-row.ai { align-self: flex-start; }
.msg-avatar { border-radius: 50%; width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; font-weight: 600; color: #fff; border: 2px solid #fff; box-shadow: var(--shadow-sm); flex: none; }
.msg-row.ai .msg-avatar { background: var(--primary-color); }
.msg-row.user .msg-avatar { background: var(--accent-color); color: #2b2b2b; }

.msg-bubble { padding: 1rem 1.25rem; border-radius: 14px; font-size: 1rem; line-height: 1.6; word-break: break-word; background: var(--article-bg); box-shadow: 0 6px 18px rgba(0,0,0,0.04); border: 1px solid rgba(0,0,0,0.03); }
.msg-row.user .msg-bubble { background: var(--article-bg); border-radius: 16px 16px 6px 16px; }
.msg-row.ai .msg-bubble { background: var(--aside-bg); border-radius: 16px 16px 16px 6px; }

/* Typographic treatments for article content */
.msg-bubble h1, .msg-bubble h2, .msg-bubble h3 { font-family: var(--font-heading); color: var(--text-primary); margin-top: 1rem; margin-bottom: 0.5rem; font-weight: 700; line-height: 1.2; }
.msg-bubble h1 { font-size: 1.45rem; }
.msg-bubble h2 { font-size: 1.25rem; }
.msg-bubble h3 { font-size: 1.05rem; }
.msg-bubble p { margin-bottom: 0.85rem; color: var(--text-secondary); }
.msg-bubble a { color: var(--primary-color); text-decoration: underline; }
.msg-bubble a:hover { color: var(--primary-hover); }
.msg-bubble blockquote { border-left: 4px solid var(--accent-color); margin-left: 0; padding-left: 1rem; color: var(--text-secondary); font-style: italic; background: rgba(176,137,58,0.03); }

/* Fix emoji clipping inside message bubbles: ensure enough line-height and visible overflow */
.msg-bubble {
    /* allow emoji glyphs room and prevent clipping by parent */
    line-height: 1.55; /* slightly reduced from 1.6 but kept roomy */
    overflow: visible;
}
.msg-bubble .thinking,
.msg-bubble .dots,
.msg-bubble .dots span {
    display: inline-block;
    vertical-align: middle;
    line-height: 1.2; /* prevents internal spans from collapsing */
}

/* Code and preformatted */
.msg-bubble code { background: rgba(0,0,0,0.04); padding: 0.15em 0.4em; border-radius: 4px; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, 'Roboto Mono', 'Courier New', monospace; }
.msg-bubble pre { background: #1f1f1f; color: #e7e7e7; padding: 1rem; border-radius: 8px; overflow-x: auto; }

/* Tables */
.msg-bubble table { width: 100%; border-collapse: collapse; margin-bottom: 1rem; }
.msg-bubble th, .msg-bubble td { border: 1px solid var(--border-color); padding: 0.6rem; text-align: left; }
.msg-bubble th { background: rgba(0,0,0,0.03); }

/* Images in content */
.msg-bubble img { max-width: 100%; height: auto; border-radius: 12px; margin-top: 0.8rem; display: block; margin-left: auto; margin-right: auto; box-shadow: var(--shadow-md); cursor: zoom-in; transition: transform 0.25s ease, box-shadow 0.25s ease; }
.msg-bubble img:hover { transform: translateY(-4px); box-shadow: 0 20px 40px rgba(0,0,0,0.12); }

.img-lightbox { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(34,34,34,0.9); display: flex; align-items: center; justify-content: center; z-index: 999; }
.img-lightbox img { max-width: 92%; max-height: 92%; border-radius: 12px; }

.msg-actions { display:flex; gap:0.5rem; margin-top:0.75rem; }
.msg-actions button { background: rgba(255,255,255,0.85); border: 1px solid var(--border-color); color: var(--text-secondary); padding: 0.4rem; border-radius: 6px; cursor: pointer; }
.msg-actions button:hover { background: var(--primary-color); color: #fff; border-color: var(--primary-color); }

/* Small screens */
@media (max-width: 992px) {
    .sidebar { position: fixed; top: var(--header-height); left: -320px; z-index: 99; height: calc(100vh - var(--header-height)); transition: left 0.25s ease-in-out; }
    .sidebar.open { left: 0; }
    .input-bar-container { left: 0; padding: 1rem; }
}

@media (max-width: 480px) {
    .brand-logo { height: 44px; max-width: 160px; }
    .page-header { padding: 0 1rem; }
}

/* Ensure flexible widths */
.main-wrapper, .main-chat-area, .chat-area, .msg-row, .msg-bubble { max-width: 100%; }

/* Small decorative touches */
.page-header .nav-meta { color: var(--text-secondary); font-size: 0.95rem; }

/* Accessibility: focus states */
a:focus, button:focus, .img-thumb:focus { outline: 3px solid rgba(122,31,31,0.12); outline-offset: 2px; }

.footer {
  background-color: #1b2c4a; /* same blue as in image */
  color: #fff;
  padding: 40px 20px;
  font-family: 'Exo 2';
}

.footer-container {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  max-width: 1200px;
  margin: 0 auto;
  flex-wrap: wrap;
}

.footer-left,
.footer-middle,
.footer-right {
  flex: 1;
  min-width: 250px;
  margin: 15px;
}

.footer-logo {
  width: 100px;
  margin-bottom: 10px;
  padding: 8px;
}

.footer-left{
  flex: 1.5;
}

.footer-left p {
  font-size: 14px;
  line-height: 1.5;
}

.footer-left a {
  text-decoration: none;
}

.footer-middle h3,
.footer-right h3 {
  margin-bottom: 10px;
  color: white;
}

.footer-right {
  color: rgba(255, 255, 255, .6);
}

.footer-right a {
  color: #1bb0ce;
}

.footer-right ul,
.footer-middle ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.footer-right ul li,
.footer-middle ul li {
  margin-bottom: 8px;
}

.footer-middle ul li a {
  color: #1bb0ce;
  text-decoration: none;
  font-size: 14px;
}

.footer-middle ul li a:hover {
  text-decoration: underline;
}

.footer-right p {
  font-size: 14px;
  margin: 4px 0;
}

.footer-right h3 a {
  color: #fff;
  text-decoration: none;
}

.footer-right h3 a:hover {
  text-decoration: underline;
}

.main-wrapper {
    height: calc(100vh - 100px); /* Subtract header height */
    display: flex;
    flex-direction: column;
}

.main-chat-area {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0; /* Important for flexbox */
}

.chat-area {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 1rem;
}

.input-bar-container {
    flex-shrink: 0;
    padding: 1rem;
    background: white;
    border-top: 1px solid #e0e0e0;
}

.footer {
    flex-shrink: 0;
    background: #2c3e50;
    color: white;
    padding: 1rem 0;
}

/* Desktop layout adjustments */
@media (min-width: 768px) {
    .main-wrapper {
        flex-direction: row;
        height: 100vh;
    }
    
    .main-chat-area {
        flex: 1;
        display: flex;
        flex-direction: column;
    }
    
    .sidebar {
        width: 280px;
        flex-shrink: 0;
    }
}

/* Footer styles */
.footer-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

.footer-mobile p,
.footer-desktop p {
    margin: 0;
    font-size: 0.9rem;
    opacity: 0.9;
}

.footer-middle h3,
.footer-right h3 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    color: #ecf0f1;
}

.footer-middle ul,
.footer-right ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.footer-middle ul li,
.footer-right ul li {
    margin-bottom: 0.3rem;
}

.footer-middle ul li a,
.footer-right ul li a {
    color: #bdc3c7;
    text-decoration: none;
    font-size: 0.9rem;
}

.footer-middle ul li a:hover,
.footer-right ul li a:hover {
    color: white;
    text-decoration: underline;
}

.footer-right ul li {
    color: #bdc3c7;
    font-size: 0.9rem;
}
