@font-face {
    font-family: 'VazirmatnLocal';
    src: local('Vazirmatn'), local('Vazirmatn Regular');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'VazirmatnLocal';
    src: local('Vazirmatn Bold'), local('Vazirmatn');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

:root {
    --app-font-family: 'VazirmatnLocal', Tahoma, 'Segoe UI', Arial, sans-serif;
    --bg-base: #0f1c36;
    --bg-gradient-start: #091428;
    --bg-gradient-mid: #16325f;
    --bg-gradient-end: #31548e;
    --surface: #fff9ea;
    --surface-soft: #f5ecd2;
    --surface-strong: #ebddb8;
    --glass-surface: rgba(255, 243, 204, 0.1);
    --glass-border: rgba(246, 210, 108, 0.28);
    --panel-dark: rgba(10, 27, 58, 0.9);
    --topbar-bg: linear-gradient(135deg, #08152e, #183967);
    --primary: #d4a72c;
    --primary-strong: #b88b14;
    --primary-soft: #f3e1a3;
    --accent: #f2c94c;
    --accent-strong: #c99a1f;
    --success: #8da94a;
    --danger: #bf5a48;
    --danger-soft: rgba(191, 90, 72, 0.16);
    --text: #1b2433;
    --text-soft: #5b6473;
    --text-on-dark: #fff8e7;
    --border: #d9c68f;
    --border-strong: #bfa15d;
    --shadow-soft: 0 10px 30px rgba(3, 12, 27, 0.22);
    --shadow-strong: 0 20px 45px rgba(1, 8, 20, 0.36);
}

body,
html {
    font-family: var(--app-font-family) !important;
    background: var(--bg-base);
    margin: 0;
    padding: 0;
    direction: rtl;
    color: var(--text);
}

/* =========================
   LOGIN PAGE OVERRIDES
   ========================= */
body.login-page, html.login-page {
    margin: 0;
    padding: 0;
    min-height: 100%;
    background: linear-gradient(135deg, var(--bg-gradient-start), var(--bg-gradient-mid), var(--bg-gradient-end));
    background-attachment: fixed;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

body.login-page {
    min-height: 100vh;
}

#particles-js {
    position: fixed;
    width: 100%;
    height: 100%;
    inset: 0;
    z-index: 0;
    pointer-events: none;
}

#particles-js,
#particles-js canvas,
.particles-js-canvas-el {
    pointer-events: none !important;
}

.login-page .login-box {
    position: relative;
    z-index: 1;
    backdrop-filter: blur(3px);
    background-color: var(--glass-surface);
    border: 1px solid var(--glass-border);
    border-radius: 1rem;
    padding: 2rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.25);
    color: var(--text-on-dark);
    direction: rtl;
}

.login-page .login-box h2 {
    text-align: center;
    font-size: 1.5rem;
    margin-bottom: 1rem;
    font-weight: bold;
    color: var(--text-on-dark);
}

.login-page .login-box input {
    width: 100%;
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    border-radius: 0.5rem;
    border: 1px solid rgba(250, 223, 135, 0.34);
    background: rgba(255, 244, 208, 0.08);
    color: var(--text-on-dark);
    outline: none;
    direction: rtl;
    text-align: right;
    font-family: inherit;
}

.login-page .login-box input::placeholder {
    color: rgba(255, 248, 231, 0.72);
    text-align: right;
}

.login-page .remember-me-option {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    margin: 4px 0 16px 0;
    color: var(--text-on-dark);
    font-size: 0.96rem;
    cursor: pointer;
}

.login-page .remember-me-option input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--primary);
    flex: 0 0 auto;
}

.login-page .remember-me-option span {
    color: inherit;
}

.login-page .login-box button {
    width: 100%;
    padding: 0.75rem;
    border: none;
    border-radius: 0.5rem;
    background: linear-gradient(135deg, var(--primary), #f0c95d);
    color: var(--text-on-dark);
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.login-page .login-box button:hover {
    transform: translateY(-1px);
    opacity: 0.95;
}

.login-page .error {
    background: rgba(178, 84, 70, 0.72);
    padding: 0.5rem;
    margin-bottom: 1rem;
    border-radius: 0.5rem;
    text-align: center;
    color: var(--text-on-dark);
}

.login-page .helper-text {
    font-size: 0.85rem;
    line-height: 1.7;
    margin-top: 1rem;
    color: rgba(255, 248, 231, 0.92);
    list-style: disc;
    padding-right: 1rem;
    direction: rtl;
    text-align: right;
}


.login-box {
    background: var(--surface);
    padding: 22px 22px 12px 22px;
    border-radius: 10px;
    margin: 40px auto 24px auto;
    max-width: 380px;
    min-width: 240px;
    box-shadow: var(--shadow-soft);
    font-family: inherit;
    direction: rtl;
}

@media (max-width: 600px) {
    .login-box {
        max-width: 97vw;
        /*margin: 18px 2vw 8px 2vw;*/
        padding: 12px 3vw 10px 3vw;
    }
}

.login-box input,
.login-box button {
    width: 100%;
    min-width: 0;
    margin: 0 0 14px 0;
    font-size: 1rem;
    box-sizing: border-box;
}

.login-box .remember-me-option input {
    width: 18px;
    min-width: 18px;
}

.login-box input {
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 5px;
    direction: rtl;
    text-align: right;
    font-family: inherit;
}

.login-box button {
    padding: 12px 0;
    background: var(--primary);
    color: var(--text-on-dark);
    border-radius: 5px;
    border: none;
    cursor: pointer;
    font-size: 1.05rem;
    font-family: inherit;
    margin-bottom: 6px;
    transition: background 0.2s;
}

.login-box button:active,
.login-box button:focus {
    outline: none;
    background: var(--primary-strong);
}

.login-box .helper-text {
    display: block;
    font-size: 14px;
    color: var(--text-soft);
    margin-top: 8px;
    margin-bottom: 2px;
    text-align: right;
    line-height: 1.6;
    font-family: inherit;
}

.top-bar,
.chat-box,
.search-form,
ul.user-list,
h2,
form,
label,
div,
span,
input,
button,
a,
li {
    font-family: var(--app-font-family) !important;
    direction: rtl;
    box-sizing: border-box;
}

h2{
    font-size: 1.2rem;
}

/* =========================
   HOME PAGE OVERRIDES
   ========================= */
body.home-page, html.home-page {
    margin: 0;
    padding: 0;
    height: 100%;
    background: linear-gradient(135deg, var(--bg-gradient-start), var(--bg-gradient-mid), var(--bg-gradient-end));
    background-attachment: fixed;
    overflow: hidden;
}

/* particles background same as login */
body.home-page #particles-js {
    position: fixed;
    width: 100%;
    height: 100%;
    inset: 0;
    z-index: 0;
    pointer-events: none;
}

/* top bar with cyan gradient */
.home-page .top-bar {
    background: var(--topbar-bg);
    color: var(--text-on-dark);
    border-radius: 0; /* remove rounded so it spans full width */
    box-shadow: var(--shadow-strong);
    z-index: 2;
}

/* glass button same as login box */
.home-page .glass-btn {
    display: block;
    margin: 30px auto 0 auto;
    padding: 15px 0;
    width: 92%;
    max-width: 350px;
    text-align: center;

    backdrop-filter: blur(6px);
    background-color: var(--glass-surface);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.25);

    color: var(--text-on-dark);
    font-size: 1.15rem;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.home-page .glass-btn:hover {
    transform: translateY(-1px);
    opacity: 0.95;
}


.top-bar {
    background: var(--topbar-bg);
    color: var(--text-on-dark);
    /*border-radius: 7px;*/
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100vw;
    z-index: 999;
    height: 4.5rem;
    min-height: 4.5rem;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.top-bar a {
    text-decoration: none !important;
}

.top-bar-status {
    font-size: 0.9rem;
    opacity: 0.95;
}

.top-bar-form {
    margin: 0;
}

.top-bar-link-btn {
    background: none;
    border: none;
    color: var(--text-on-dark);
    cursor: pointer;
    font: inherit;
    padding: 0;
}

.top-bar-link-btn:hover,
.top-bar-link-btn:focus {
    color: #ffe29a;
    outline: none;
}

.chat-top-bar {
    direction: ltr;
    justify-content: flex-start;
    gap: 16px;
    padding: 0 24px;
}

.chat-back-link {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-on-dark);
    font-size: 1rem;
    white-space: nowrap;
    direction: ltr;
}

.chat-back-text {
    direction: rtl;
}

.chat-top-bar-center {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-width: 0;
    direction: rtl;
}

.chat-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-on-dark);
}

.chat-crypto-status {
    font-size: 0.9rem;
    margin-top: 6px;
    opacity: 0.95;
    color: rgba(255, 248, 231, 0.9);
}

.chat-top-bar-spacer {
    flex: 0 0 190px;
}


@media (max-width: 600px) {
    .top-bar {
        max-width: 100vw;
        padding: 10px 3vw;
        margin-bottom: 8px;
    }

    .chat-top-bar {
        padding: 10px 12px;
        gap: 8px;
    }

    .chat-back-link {
        font-size: 0.92rem;
    }

    .chat-title {
        font-size: 1rem;
    }

    .chat-top-bar-spacer {
        flex-basis: 120px;
    }
}

.user-list {
    list-style: none;
    padding: 0;
    margin: 0;
    text-align: right;
    direction: rtl;
    max-width: 400px;
    margin: 0 auto;
    text-align: center;
}

.user-list li {
    padding: 8px 0;
    direction: rtl;
}

.user-list a {
    color: var(--text-on-dark);
    text-decoration: none;
    font-size: 1rem;
    word-break: break-all;
    direction: rtl;
    font-family: inherit;
}

.mine,
.theirs {
    text-align: right;
    margin: 5px;
    border-radius: 5px;
    padding: 5px 12px 5px 5px;
    direction: rtl;
    word-break: break-word;
    overflow-wrap: anywhere;
    white-space: pre-line;
    max-width: 98%;
    box-sizing: border-box;
}

.mine {
    background: linear-gradient(135deg, #f0c95d, #d8a11a);
    color: #18233d;
    box-shadow: 0 8px 18px rgba(9, 20, 40, 0.16);
}

.theirs {
    background: rgba(255, 249, 234, 0.96);
    color: var(--text);
    border: 1px solid rgba(212, 167, 44, 0.26);
    box-shadow: 0 8px 18px rgba(9, 20, 40, 0.08);
}

.t {
    font-size: 11px;
    color: var(--text-soft);
    margin-left: 8px;
    margin-right: 0;
    direction: rtl;
}

.error {
    color: var(--danger);
    margin: 10px 0;
    text-align: center;
    direction: rtl;
}

h2 {
    text-align: center !important;
    direction: rtl;
    font-family: inherit;
    margin-bottom: 18px;
    margin-top: 0;
}

label {
    font-family: inherit;
    direction: rtl;
}

form {
    direction: rtl;
    text-align: right;
    font-family: inherit;
}

.search-form {
    max-width: 400px;
    margin: 0 auto 18px auto;
    text-align: right;
}

.home-search-title {
    color: var(--text-on-dark);
    text-align: right !important;
    text-shadow: 0 2px 14px rgba(0, 0, 0, 0.24);
}

.search-form {
    max-width: 440px;
    margin: 52px auto 22px auto;
    display: flex;
    flex-direction: row;
    gap: 10px;
    justify-content: center;
    align-items: center;
    /*background: #fff;*/
    border-radius: 10px;
    padding: 16px 14px 16px 14px;
    background: rgba(255, 244, 214, 0.14);
    border: 1px solid rgba(246, 210, 108, 0.18);
    box-shadow: var(--shadow-soft);
    font-family: inherit;
}

.search-form input[type="text"] {
    flex: 1 1 auto;
    font-size: 1.05rem;
    padding: 12px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin: 0;
    font-family: inherit;
    direction: rtl;
    text-align: right;
    outline: none;
    transition: border 0.2s;
    background: rgba(255, 249, 234, 0.96);
    color: var(--text);
}

.search-form input[type="text"]::placeholder,
#chat-bar textarea::placeholder {
    color: var(--text-soft);
}

.search-form input[type="text"]:focus {
    border: 1.5px solid var(--primary);
    background: var(--surface);
}

.search-form button {
    padding: 12px 0;
    width: 110px;
    border-radius: 8px;
    border: none;
    background: var(--primary);
    color: var(--text-on-dark);
    font-size: 1.1rem;
    font-family: inherit;
    cursor: pointer;
    margin: 0;
    transition: background 0.2s;
}

.search-form button:active,
.search-form button:focus {
    outline: none;
    background: var(--primary-strong);
}

.search-form button:hover {
    background: var(--primary-strong);
}

@media (max-width: 600px) {
    .search-form {
        flex-direction: column;
        padding: 12px 4vw 12px 4vw;
        gap: 8px;
        max-width: 97vw;
    }
    .search-form input[type="text"],
    .search-form button {
        border-radius: 8px !important;
        width: 100% !important;
    }
}

.start-chat-btn {
    /*display: block;
    margin: 30px auto 0 auto;
    padding: 15px 0;
    width: 92%;
    max-width: 350px;
    background: #22c55e;
    color: #fff;
    border-radius: 10px;
    border: none;
    font-size: 1.15rem;
    font-family: inherit;
    text-align: center;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(34,197,94,0.07);
    text-decoration: none;
    transition: background 0.18s, box-shadow 0.18s;*/
    position: relative;
    z-index: 1;
    backdrop-filter: blur(6px);
    background-color: var(--glass-surface);
    border: 1px solid var(--glass-border);
    border-radius: 0.5rem;
    padding: 2rem;
    width: 92%;
    max-width: 420px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.25);
    color: var(--text-on-dark);
    direction: rtl;
    
        margin: 30px auto 0 auto;
    padding: 15px 0;
    max-width: 350px;
    font-size: 1.15rem;
    cursor: pointer;
    transition: background 0.18s, box-shadow 0.18s;
}
.start-chat-btn:active,
.start-chat-btn:focus,
.start-chat-btn:hover {
    background: rgba(246, 210, 108, 0.18);
    outline: none;
}

.recent-chats {
    color: var(--text-on-dark);
    font-size: 1.5rem;
}

.recent-chats-wrap {
    margin: 18px 0 0 0;
    text-align: center;
}

.recent-chat-item {
    position: relative;
}

.recent-chat-link {
    padding: 10px 0;
    margin: 8px 0 0 0;
    font-size: 1rem;
    width: 80%;
    display: inline-block;
    position: relative;
}

#chat-bar {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    width: 100%;
    max-width: 400px;
    margin: 10px auto 10px auto;
    background: rgba(255, 249, 234, 0.98);
    border-radius: 10px;
    padding: 12px 10px 8px 10px;
    box-sizing: border-box;
    box-shadow: var(--shadow-soft);
}

#chat-bar textarea {
    flex: 1 1 auto;
    min-height: 50px;
    max-height: 120px;
    resize: none;
    font-size: 1.08rem;
    padding: 10px 8px 10px 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    direction: rtl;
    text-align: right;
    font-family: inherit;
    margin-left: 8px;
    margin-right: 0;
    outline: none;
    transition: border 0.17s;
    background: var(--surface-soft);
    color: var(--text);
    box-sizing: border-box;
}

#chat-bar textarea:focus {
    border: 1.5px solid var(--primary);
    background: var(--surface);
}

#chat-bar button {
    background: var(--primary);
    border: none;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    color: var(--text-on-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.55rem;
    margin-right: 0;
    margin-left: 4px;
    transition: background 0.18s;
    padding: 0;
    margin-bottom: 4px;
}

#chat-bar button:active,
#chat-bar button:focus {
    background: var(--primary-strong);
    outline: none;
}

#chat-bar button svg {
    width: 27px;
    height: 27px;
    fill: var(--text-on-dark);
    display: block;
}

.chat-form {
    margin-bottom: 0;
    text-align: right;
}

@media (max-width: 600px) {
    #chat-bar {
        max-width: 97vw;
        padding: 9px 2vw 7px 2vw;
    }
    #chat-bar textarea {
        font-size: 1rem;
    }
    #chat-bar button {
        width: 42px;
        height: 42px;
        font-size: 1.2rem;
    }
    #chat-bar button svg {
        width: 22px;
        height: 22px;
    }
}

.chat-container {
    display: flex;
    flex-direction: column;
    min-height: 95vh;
    height: 95vh;
    background: var(--bg-base);
    box-sizing: border-box;
    padding-top: 4.5rem;
}

.call-panel {
    position: relative;
    z-index: 2;
    padding: 12px;
    background: var(--panel-dark);
    backdrop-filter: blur(10px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
}

.call-panel-header {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-on-dark);
    margin: 0 auto 10px auto;
    width: min(100%, 960px);
}

.call-status {
    flex: 1 1 auto;
    font-size: 0.95rem;
    text-align: right;
}

.call-btn,
.hangup-btn {
    border: none;
    border-radius: 999px;
    color: var(--text-on-dark);
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 700;
    padding: 10px 18px;
}

.call-btn {
    background: linear-gradient(135deg, var(--primary), #f0c95d);
}

.hangup-btn {
    background: linear-gradient(135deg, var(--danger), var(--accent-strong));
}

.call-videos {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 180px;
    gap: 12px;
    width: min(100%, 960px);
    margin: 0 auto;
}

.remote-video,
.local-video {
    width: 100%;
    background: #08152e;
    border-radius: 14px;
    object-fit: cover;
    box-shadow: inset 0 0 0 1px rgba(255, 248, 231, 0.08);
}

.remote-video {
    min-height: 220px;
    max-height: 280px;
}

.local-video {
    min-height: 120px;
    max-height: 280px;
}

#chat-bar {
    position: fixed;
    right: 0;
    left: 0;
    bottom: 0;
    z-index: 99;
    max-width: 100vw;
    width: 100vw;
    border-radius: 0;
    box-shadow: 0 -3px 12px rgba(0,0,0,0.09);
    margin: 0;
}

/*@media (max-width: 600px) {
    #chat-bar {
        padding: 9px 2vw 7px 2vw;
    }
}*/

.chat-box {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    font-size: 1rem;
    direction: rtl;
    margin: 0;
    max-width: 100vw;
    width: 100%;
    background: linear-gradient(180deg, #16325f, #224679 48%, #0f1c36);
    border-radius: 7px;
    padding-top: 12px;
    padding-bottom: 88px;
}

.search-error {
    margin-top: 24px;
}
@media (max-width: 600px) {
    .call-panel {
        padding: 10px 8px;
    }

    .call-panel-header {
        flex-wrap: wrap;
    }

    .call-status {
        width: 100%;
        order: 3;
    }

    .call-videos {
        grid-template-columns: 1fr;
    }

    .remote-video {
        min-height: 170px;
    }

    .local-video {
        min-height: 120px;
    }

    .chat-box {
        padding-top: 12px;
        padding-bottom: 3.5rem;
        max-width: 100vw;
        max-height: none;
        min-height: 0;
        margin-bottom: 0 !important;
    }
}

@media (max-width: 600px) {
    .chat-container {
        min-height: 100vh;
        height: 100vh;
        max-height: 100vh;
        padding-bottom: 8px;
    }
}

.better-list {
    list-style-type: disc;
    list-style-position: outside;
    padding-right: 28px;
    font-size: 15px;
    line-height: 2;
    margin-top: 18px;
    margin-bottom: 0;
    direction: rtl;
}

.better-list li {
    text-align: justify;
    direction: rtl;
    padding-right: 0;
    margin-bottom: 6px;
}

.unread-badge {
    position: absolute;
    top: -15px;
    left: 2px;
    background: var(--accent);
    color: var(--text-on-dark);
    border-radius: 50%;
    min-width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.93rem;
    font-weight: bold;
    z-index: 3;
    box-shadow: 0 2px 8px rgba(0,0,0,0.13);
    border: 2px solid var(--surface);
}
