/* =========================================
   Fonts and base settings
   ========================================= */
@font-face {
    font-family: 'Vazir';
    src: url('../fonts/Vazir/Vazir-Regular.woff2') format('woff2'),
         url('../fonts/Vazir/Vazir-Regular.woff') format('woff');
    font-weight: 300;
    font-style: normal;
}

:root {
    --primary: #28a745;
    --primary-hover: #218838;
    --bg-main: #efefef;
    --card-border: #eee;
    --msg-mine: #fffdf5;
    --msg-other: #ffffff;
    --nav-bg: #f8f9fa;
    --text-color: #262626;
}

/* =========================================
   Theme Overrides
   ========================================= */

.theme-gold {
    --primary: #d4af37;
    --primary-hover: #c29a28;
    --bg-main: #f8f5ec;
    --card-border: #d8bf6a;
    --msg-mine: #fbf7ea;
    --msg-other: #fffcf6;
    --nav-bg: linear-gradient(135deg, #d8bf6a 0%, #f3e5a8 22%, #e6cc6a 42%, #d4af37 62%, #e0c15a 82%, #c9a227 100%);
    --text-color: #4a3d12;
}

.theme-midnight {
    --primary: #243b6b;
    --primary-hover: #1b2f57;
    --bg-main: #f5f7fb;
    --card-border: #cfd8ea;
    --msg-mine: #edf2fb;
    --msg-other: #ffffff;
    --nav-bg: linear-gradient(135deg, #dfe7f5 0%, #cfdaf0 45%, #b9c8e6 100%);
    --text-color: #24324a;
}

.theme-rosegold {
    --primary: #e0aaaf;
    --primary-hover: #c77d85;
    --bg-main: #fff5f6;
    --card-border: #e0aaaf;
    --msg-mine: #fff9fa;
    --msg-other: #ffffff;
    --nav-bg: linear-gradient(to right, #e0aaaf, #f8d7da);
}

.theme-candy {
    --primary: #ff7eb6;
    --primary-hover: #ff5c9a;
    --bg-main: #fff7fb;
    --card-border: #ffd1e6;
    --msg-mine: #fff0f7;
    --msg-other: #ffffff;
    --nav-bg: linear-gradient(135deg, #ff9ecf 0%, #ffd6e7 50%, #ffe9f2 100%);
    --text-color: #4a2f3f;
}

.theme-mint {
    --primary: #4ebaa6;
    --primary-hover: #3d9685;
    --bg-main: #f4faf8;
    --card-border: #bfe7df;
    --msg-mine: #eef9f6;
    --msg-other: #ffffff;
    --nav-bg: linear-gradient(135deg, #baf2e3 0%, #dff7ef 100%);
    --text-color: #23413a;
}

.theme-sunset {
    --primary: #ff8b94;
    --primary-hover: #ff6f7a;
    --bg-main: #fffaf7;
    --card-border: #ffd3b6;
    --msg-mine: #fff3ea;
    --msg-other: #ffffff;
    --nav-bg: linear-gradient(135deg, #ffb199 0%, #ffd6a5 50%, #fff1cf 100%);
    --text-color: #5a3b2e;
}

.theme-night-cute {
    --primary: #9b5de5;
    --primary-hover: #f15bb5;
    --bg-main: #151227;
    --card-border: #4f3b8a;
    --msg-mine: #211944;
    --msg-other: #1a1536;
    --nav-bg: linear-gradient(135deg, #2d1b69 0%, #6a3fa0 50%, #a14dbf 100%);
    --text-color: #f3efff;
}

.theme-sky {
    --primary: #4da3ff;
    --primary-hover: #2f8ef0;
    --bg-main: #f4faff;
    --card-border: #b9dcff;
    --msg-mine: #eef7ff;
    --msg-other: #ffffff;
    --nav-bg: linear-gradient(135deg, #d9efff 0%, #bfe3ff 45%, #9fd4ff 100%);
    --text-color: #23415e;
}

/* =========================================
   Base typography
   ========================================= */
* {
    font-family: 'Vazir', Tahoma, sans-serif;
    font-feature-settings: "ss01" 1;
    -webkit-font-feature-settings: "ss01" 1;
    -moz-font-feature-settings: "ss01" 1;
}

html {
    font-size: 12px !important;
    direction: rtl;
    height: 100%;
}

body {
    text-align: right;
    background-color: var(--bg-main);
    margin: 0;
    height: 100%;
    color: var(--text-color);
    font-weight: 300;
    line-height: 1.7;
    font-variant-numeric: normal;
    font-feature-settings: "locl" 1, "numr" 1, "dnom" 1;
    direction: rtl;
    unicode-bidi: plaintext;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Vazir', Tahoma, sans-serif;
    font-weight: 600;
}

/* =========================================
   Components
   ========================================= */

/* Navbar */
.custom-navbar {
    background: var(--nav-bg);
    box-shadow: 0 4px 10px rgba(36, 59, 107, 0.12);
    border: none;
}

/* Messages */
.message-box {
    font-size: 14px;
    width: fit-content;
    max-width: 85%;
    display: block;
    clear: both;
    touch-action: manipulation;
}

.message-box a,
.message-box .reply,
.message-box .del-btn,
.message-box .avatar-wrapper {
    -webkit-user-select: none;
    user-select: none;
}

.my-message {
    background-color: var(--msg-mine) !important;
    border: 1px solid lightgray !important;
    color: var(--text-color);
    margin-right: 0 !important;
    margin-left: auto !important;
}

.other-message {
    background-color: var(--msg-other) !important;
    border: 1px solid #e0e0e0 !important;
    color: var(--text-color);
    margin-right: auto !important;
    margin-left: 0 !important;
}

/* Gallery */
.gallery-card {
    background-color: var(--msg-other) !important;
    border: 2px solid var(--card-border) !important;
    border-radius: 14px;
    overflow: hidden;
    color: var(--text-color);
}

.img-gallery-item {
    object-fit: contain;
    width: 100%;
    height: 100%;
}

/* Submit button */
#submit-btn {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary) 45%, var(--primary-hover) 100%);
    border: none;
    color: #ffffff;
    font-weight: 700;
    height: 30px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    border-radius: 10px;
}

#submit-btn:disabled {
    background: #ccc !important;
    cursor: not-allowed;
    box-shadow: none;
}

/* Avatar and online status */
.avatar-wrapper {
    position: relative !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
}

.avatar-circle {
    position: relative;
    z-index: 1;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    background: #6c757d;
    color: #fff;
    flex-shrink: 0;
}

.online-dot {
    position: absolute !important;
    bottom: -1px;
    right: -1px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #28a745;
    border: 1px solid #ffffff;
    display: none;
    z-index: 5;
}

.message-box.is-online .online-dot {
    display: block;
}

/* Header action buttons */
.nav-action-btn {
    padding: 0.5rem 1rem;
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none !important;
    border: 1px solid var(--primary);
    color: var(--primary-hover) !important;
    background: rgba(255, 255, 255, 0.8);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.nav-action-btn:hover {
    background: var(--primary);
    color: #ffffff !important;
}

/* Dark & Midnight Theme specific fixes */
.theme-night-cute .my-message,
.theme-night-cute .other-message,
.theme-midnight .my-message,
.theme-midnight .other-message {
    border-color: var(--card-border) !important;
}

.theme-midnight .online-dot {
    border-color: var(--nav-bg);
}

.online-dot-inline {
    position: static !important;
    width: 8px;
    height: 8px;
    min-width: 8px;
    min-height: 8px;
    border-radius: 50%;
    background-color: #28a745;
    border: 1px solid #ffffff;
    display: none;
    z-index: 1;
}

.message-box.is-online .online-dot-inline {
    display: inline-block;
}

#new-messages-banner {
    position: sticky;
    top: 0;
    z-index: 20;
    border-radius: 12px;
    user-select: none;
}

#new-messages-count {
    min-width: 32px;
    text-align: center;
    font-size: 0.9rem;
}
