@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;500;600;700&display=swap');
html,body{height:100%;}
body{margin:0;font-family:'Cairo',Tahoma,Verdana,Arial,sans-serif;font-size:14px;direction:rtl;background:#e9eff6;color:#172a45;}
a{color:inherit;}
button,input,select,textarea{font-family:inherit;font-size:inherit;}

.app-shell{display:flex;min-height:100vh;}
.sidebar{flex-shrink:0;width:240px;background:#0f1f3d;color:#f4f6ff;padding:20px 18px;display:flex;flex-direction:column;gap:18px;border-left:1px solid rgba(255,255,255,.08);}
.sidebar-brand{font-size:20px;font-weight:700;color:#fff;margin-bottom:4px;}
.sidebar-user{font-size:14px;color:#d8e1ff;}
.sidebar-nav{display:flex;flex-direction:column;gap:10px;}
.sidebar-nav a{display:block;padding:10px 14px;border-radius:10px;color:#f4f6ff;text-decoration:none;border:1px solid transparent;transition:all .2s ease;}
.sidebar-nav a:hover{background:rgba(255,255,255,.08);border-color:rgba(255,255,255,.12);}
.sidebar-nav a.active{background:rgba(255,255,255,.14);border-color:rgba(255,255,255,.2);font-weight:700;}
.main-content{flex:1;background:#f4f7fb;}
.container{max-width:1100px;margin:0 auto;padding:20px;}
body.has-djchat .container{max-width:none;}

@media (max-width:900px){
    .app-shell{flex-direction:column;}
    .sidebar{width:100%;border-left:none;border-bottom:1px solid rgba(0,0,0,.08);padding:16px;}
    .sidebar-nav{flex-direction:row;flex-wrap:wrap;gap:8px;}
    .sidebar-nav a{flex:1 1 auto;}
    .main-content{padding:0;}
}

.box{padding:22px;border:1px solid rgba(14,36,71,.12);border-radius:18px;box-shadow:0 18px 50px rgba(39,80,148,.08);background:#fff;margin-bottom:20px;}
.btn{padding:11px 18px;border:1px solid transparent;background:linear-gradient(135deg,#1f66d2,#1f97ff);color:#fff;cursor:pointer;border-radius:12px;transition:transform .18s ease,box-shadow .18s ease,opacity .18s ease;text-decoration:none;display:inline-flex;align-items:center;justify-content:center;}
.btn:hover{transform:translateY(-1px);box-shadow:0 12px 24px rgba(31,102,210,.22);opacity:.98;}
.btn:disabled{opacity:.6;cursor:not-allowed;}
input[type=text],input[type=password],input[type=email],select,textarea{width:100%;padding:12px;border:1px solid rgba(14,36,71,.18);border-radius:12px;background:#fafbff;box-sizing:border-box;outline:none;transition:border-color .2s ease,box-shadow .2s ease;}
input[type=text]:focus,input[type=password]:focus,input[type=email]:focus,select:focus,textarea:focus{border-color:#1b5cb8;box-shadow:0 0 0 4px rgba(31,102,210,.12);}
label{display:block;margin-bottom:6px;font-weight:600;color:#283c5b;}

#chat-layout{display:grid;grid-template-columns:220px 1fr 220px;gap:10px;}
.dm-layout{display:grid;grid-template-columns:280px 1fr;gap:10px;}
.panel-title{font-weight:bold;margin-bottom:10px;color:#102746;}

#chat-log{height:520px;overflow:auto;border-radius:16px;border:1px solid rgba(14,36,71,.12);padding:14px;background:#fff;}
.msg{padding:2px 0;}
.msg .t{opacity:.7;}
.msg .u{font-weight:bold;}
.msg .u.role-admin{color:#1db954;}
.msg .u.role-mod{color:#1c7ad9;}
.msg .u.role-vip{color:#aa33cc;}

#chat-form{display:flex;gap:10px;margin-top:14px;}
#chat-input{flex:1;padding:12px;border:1px solid rgba(14,36,71,.18);border-radius:12px;background:#fafbff;}
.dm-thread{padding:10px 0;border-bottom:1px solid rgba(14,36,71,.12);cursor:pointer;}
.dm-thread.active{background:#eef5ff;}
#dm-log{height:520px;overflow:auto;border-radius:16px;border:1px solid rgba(14,36,71,.12);padding:14px;background:#fff;}
#dm-form{display:flex;gap:10px;margin-top:14px;}
#dm-input{flex:1;padding:12px;border:1px solid rgba(14,36,71,.18);border-radius:12px;background:#fafbff;}
.btn{padding:10px 16px;border:1px solid transparent;background:linear-gradient(135deg,#1f66d2,#1f97ff);color:#fff;cursor:pointer;border-radius:12px;transition:transform .18s ease,box-shadow .18s ease,opacity .18s ease;text-decoration:none;display:inline-flex;align-items:center;justify-content:center;}

.djchat{width:100%;}
.djchat-window{border:2px solid #0b2b55;background:#c9d7ef;display:flex;flex-direction:column;height:calc(100vh - 24px);}
.djchat-header{display:flex;align-items:center;justify-content:space-between;padding:10px 14px;background:linear-gradient(#2f67b2,#0f3f86);color:#fff;border-bottom:2px solid #082244;}
.djchat-title{font-weight:bold;font-size:18px;letter-spacing:.35px;}
.djchat-header-actions{display:flex;gap:10px;align-items:center;}
.djchat-link{text-decoration:none;color:inherit;opacity:.95;}
.djchat-link:hover{opacity:1;text-decoration:underline;}

.djchat-body{display:grid;grid-template-columns:280px 1fr;gap:10px;padding:10px;flex:1;min-height:0;}
.djchat-left,.djchat-center{border:1px solid #082244;background:#f5f9ff;}
.djchat-panel-title{font-weight:bold;padding:8px 10px;background:linear-gradient(#dfe8f8,#b8cceb);border-bottom:1px solid #082244;color:#0b2b55;}
.djchat-users-filter{display:flex;gap:6px;padding:8px 10px;background:#eef4ff;border-bottom:1px solid #c0cfe0;flex-wrap:wrap;}
.djchat-users-filter .djbtn{padding:6px 11px;min-width:90px;white-space:nowrap;}
.djchat-panel-body{padding:10px;}
.djchat-room-active{padding:6px;border:1px dotted #666;background:#f7f7f7;}

.djchat-left,.djchat-center{min-height:0;}
.djchat-center{display:flex;flex-direction:column;min-height:0;}
.djchat-room-bar{padding:8px 10px;background:linear-gradient(#f7fbff,#d7e6fb);border-bottom:1px solid #082244;}
.djchat-room-name{font-weight:bold;font-size:16px;}
.djchat-announcement{margin:8px 10px 0 10px;padding:10px 14px;background:linear-gradient(135deg,#fff9db,#fff1b4);border:1px solid #ffd27f;color:#20313b;border-radius:14px;box-shadow:0 3px 10px rgba(0,0,0,0.08);font-weight:700;line-height:1.4;}
.djchat-alert{margin:10px 10px 0 10px;padding:10px;border:1px solid #555;background:#111;color:#ffd;}
.djchat-log{flex:1;min-height:0;overflow:auto;border-top:1px solid #333;border-bottom:1px solid #333;padding:10px;background:#fffef7;}
.msg{padding:3px 0;font-size:14px;line-height:1.45;}
.msg.system{opacity:.95;color:#2f4a67;background:rgba(240,248,255,0.8);padding:8px 10px;border-radius:10px;margin:6px 0;}
.msg.action{font-style:italic;color:#2f2f2f;}
.msg-action{display:block;}
.msg .t{opacity:.7;font-size:12px;}
.msg .u{font-weight:bold;font-family:Arial,Helvetica,sans-serif;}
.retrochat-toast{cursor:pointer;}
.retrochat-toast:hover{background:rgba(0,0,0,0.95);}
.msg .u.role-admin{color:#1db954;}
.msg .u.role-mod{color:#1c7ad9;}
.msg .u.role-vip{color:#aa33cc;}
.djchat-log .u{cursor:pointer;color:#0045a9;}
.djchat-log .u:hover{opacity:.85;text-decoration:underline;}
.djchat-input-wrap{padding:10px 12px;background:linear-gradient(#f7fbff,#e8efff);}
.djchat-form{display:flex;gap:8px;margin-top:8px;align-items:flex-end;}
.djchat-input{flex:1;padding:10px;border:1px solid #444;min-height:42px;outline:none;background:#fff;white-space:pre-wrap;word-wrap:break-word;overflow-wrap:break-word;border-radius:10px;}
.djchat-input:empty:before{content:attr(data-placeholder);color:#999;}
.djchat-input img.input-emote{display:inline-block;vertical-align:middle;max-height:24px;max-width:36px;margin-right:2px;}
.djchat-room-actions{display:flex;gap:8px;padding:8px 10px;background:linear-gradient(#f7fbff,#e8efff);border-bottom:1px solid #082244;}
.djchat-pm-status{padding:10px 12px;background:#fff4e6;border:1px solid #ffbb66;color:#333;margin:0 10px 8px;border-radius:8px;}
.djchat-view-tab.active{background:linear-gradient(#ffffff,#dcdcdc);}
.djchat-center #chat-log{height:auto;}

.djchat-toolbar{display:flex;gap:8px;align-items:center;padding:6px 0;}
.djbtn{padding:8px 10px;border:1px solid rgba(14,36,71,.12);background:transparent;cursor:pointer;font-weight:700;min-width:40px;min-height:40px;display:inline-flex;align-items:center;justify-content:center;border-radius:10px;transition:background .12s ease,transform .12s ease,box-shadow .12s ease;touch-action:manipulation;}
.djbtn:disabled{opacity:.6;cursor:not-allowed;}
.djbtn.active{background:linear-gradient(180deg,rgba(31,102,210,.12),rgba(31,102,210,.06));border-color:rgba(14,36,71,.18);box-shadow:0 6px 14px rgba(16,39,70,.06);}
.djbtn:focus{outline:none;box-shadow:0 0 0 4px rgba(31,102,210,.12);}
.djbtn:hover{transform:translateY(-2px);background:rgba(14,36,71,.04);} 
.djbtn .djico{pointer-events:none;display:inline-flex;align-items:center;justify-content:center;font-weight:700;}

.djico{display:inline-block;line-height:1;font-family:Tahoma,Verdana,Arial,sans-serif;}
.djico-b{font-weight:900;}
.djico-i{font-style:italic;}
.djico-a{font-weight:900;}
.djico-smile{font-weight:normal;}

.djchat-tabs{display:flex;gap:6px;padding:6px;background:linear-gradient(#b8cceb,#91aedc);border-bottom:1px solid #082244;}
.djtab{padding:6px 10px;border:1px solid #082244;background:linear-gradient(#ffffff,#d7e6fb);cursor:pointer;opacity:.92;color:#0b2b55;}
.djtab.active{opacity:1;background:linear-gradient(#fff7d4,#ffe08a);}
.djchat-tabpanes{height:100%;min-height:0;}
.djchat-pane{display:none;}
.djchat-pane.active{display:block;}

.djroom{padding:6px;border-bottom:1px dotted #666;}
.djroom.active{background:#f2f2f2;}

.djuser{display:flex;align-items:center;justify-content:space-between;padding:6px 8px;border-bottom:1px solid rgba(14,36,71,.06);}
.djuser .djuser-name{font-weight:600;color:#102746;}
.djuser .djuser-role{margin-left:8px;padding:4px 8px;border-radius:999px;background:rgba(16,39,70,.06);font-size:12px;color:#0b3a63;}
.djuser .djuser-badge{margin-left:8px;font-size:1rem;}
.djuser .djuser-role.djrole-vip{background:linear-gradient(90deg,#fff7e6,#fff0d1);color:#7a4b00;border:1px solid rgba(122,75,0,.08);}
.djuser .djuser-actions{display:flex;gap:8px;margin-left:10px;}
.djuser .djuser-action{padding:6px;border-radius:8px;border:1px solid rgba(14,36,71,.06);background:transparent;cursor:pointer;font-size:13px;color:#0b3a63;}
.djuser .djuser-action:hover{background:rgba(14,36,71,.04);}

.djpm-tabs{display:flex;gap:6px;flex-wrap:wrap;margin-bottom:6px;}
.djpm-tab{display:inline-flex;align-items:center;gap:6px;padding:4px 8px;border:1px solid #333;background:linear-gradient(#fff,#dcdcdc);cursor:pointer;opacity:.85;max-width:100%;position:relative;}
.djpm-tab.active{opacity:1;background:linear-gradient(#ffffff,#cfcfcf);}
.djpm-tab.unread{border-color:#c33;}
.djpm-tab.unread::after{content:'•';color:#c33;font-size:1.1em;line-height:1;position:absolute;top:4px;right:6px;}
.djpm-tab .x{border:1px solid #333;background:#fff;padding:0 6px;cursor:pointer;line-height:18px;}

.djpm-logs{min-height:0;}
.djpm-log{height:320px;overflow:auto;border:1px solid #333;padding:8px;background:#fff;}
.djpm-form{margin-top:8px;display:flex;gap:6px;}
.djpm-input{flex:1;padding:8px;border:1px solid #333;min-width:0;}

.djuser{padding:6px;border-bottom:1px dotted #666;display:flex;justify-content:space-between;gap:8px;align-items:center;}
.djuser-name{font-weight:bold;}
.djuser-role{opacity:.9;font-size:12px;white-space:nowrap;border:1px solid #333;padding:1px 6px;background:linear-gradient(#fff,#dcdcdc);}
.djuser-role.djrole-admin{background:linear-gradient(#fff3cf,#ffd27a);}
.djuser-role.djrole-mod{background:linear-gradient(#d7f5ff,#8cd8ff);}
.djuser-role.djrole-vip{background:linear-gradient(#ffe0f5,#ff9bd8);}

.djchat-footer{padding:6px 10px;border-top:1px solid #333;background:#e6e6e6;}
.djchat-footer-hint{font-size:12px;opacity:.9;}
.djchat-footer-notice{font-size:14px;line-height:1.5;color:#111;background:#fff5d8;border:1px solid #ffd97d;padding:10px 12px;border-radius:12px;box-shadow:0 2px 8px rgba(0,0,0,0.06);}

.djmodal#djmodal-overlay{position:fixed;inset:0;background:rgba(0,0,0,.35);z-index:50;}
.djmodal#djmodal{position:fixed;top:50%;left:50%;transform:translate(-50%,-50%);width:min(520px,calc(100vw - 24px));max-height:calc(100vh - 24px);overflow:auto;z-index:60;border:2px solid #333;background:#e6e6e6;}
.djmodal-head{display:flex;align-items:center;justify-content:space-between;padding:8px 10px;background:linear-gradient(#2b579a,#1e3f73);color:#fff;border-bottom:1px solid #102746;}
.djmodal-title{font-weight:bold;}
.djmodal-body{padding:10px;}
.djpalette{display:grid;grid-template-columns:repeat(8, 1fr);gap:6px;}
.djcolor{width:100%;aspect-ratio:1/1;border:1px solid #333;cursor:pointer;}
.djemotes{display:flex;flex-wrap:wrap;gap:6px;}

@media (max-width: 560px) {
    .djmodal#djmodal {
        width: calc(100vw - 16px) !important;
        max-height: 80vh !important;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
    }
    .djmodal-head { 
        padding: 8px 10px;
        flex-shrink: 0;
    }
    .djmodal-title { 
        font-size: 15px;
        font-weight: bold;
    }
    .djmodal-body { 
        padding: 10px;
        max-height: calc(80vh - 50px);
        overflow-y: auto;
        flex-shrink: 1;
    }
    .djpalette { 
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        gap: 6px;
        width: 100%;
    }
    .djcolor { 
        width: 100%;
        aspect-ratio: 1/1;
        border: 1px solid #333;
        cursor: pointer;
        font-size: 12px;
    }
    .djemotes { 
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        width: 100%;
    }
    .djemote { 
        padding: 8px 10px;
        border: 1px solid #333;
        background: #fff;
        cursor: pointer;
        border-radius: 6px;
        flex: 1 1 calc(50% - 4px);
        text-align: center;
        min-height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}
.djemote{padding:6px 8px;border:1px solid #333;background:#fff;cursor:pointer;}

.form-row{margin-bottom:10px;}
.admin-nav{display:flex;flex-wrap:wrap;gap:10px;margin:14px 0 20px;}
.admin-nav .btn{border-radius:999px;white-space:nowrap;transition:opacity .2s ease, transform .2s ease;}
.admin-nav .btn.active{opacity:1;background:#333;color:#fff;border-color:#333;transform:translateY(-1px);}
.admin-panel{display:grid;gap:16px;}
.admin-cards{display:grid;grid-template-columns:1.1fr 1.9fr;gap:16px;}
.admin-card{background:#fff;border:1px solid #ddd;border-radius:12px;box-shadow:0 8px 24px rgba(0,0,0,.06);padding:18px;}
.admin-card .panel-title{border-bottom:1px solid #eee;padding-bottom:10px;margin-bottom:16px;color:#111;}
.admin-table{width:100%;border-collapse:collapse;font-size:13px;}
.admin-table th,.admin-table td{padding:12px 10px;border:1px solid #eee;vertical-align:top;text-align:right;}
.admin-table th{background:#f8f9fa;color:#222;font-weight:700;}
.admin-badge{display:inline-block;padding:4px 10px;border-radius:999px;font-size:12px;background:#f3f4f6;color:#111;}
.admin-badge.enabled{background:#e6f9e6;color:#086114;border:1px solid #c7e6c7;}
.admin-badge.disabled{background:#fde7e7;color:#7b1212;border:1px solid #f2c7c7;}
.admin-input{width:100%;padding:10px;border:1px solid #ccd0d6;border-radius:8px;box-sizing:border-box;}
.admin-input:focus,.admin-textarea:focus{outline:none;border-color:#333;}
.admin-textarea{width:100%;min-height:120px;padding:10px;border:1px solid #ccd0d6;border-radius:8px;box-sizing:border-box;resize:vertical;}
unchanged.djemote-icon{max-height:24px;max-width:36px;vertical-align:middle;}
.error{color:#b00;margin:8px 0;}

/* Hide message timestamps based on room data attributes and role
	- hide for regular users when show_message_time_user is 0
	- hide for guests when show_message_time_guest is 0 */
#room[data-show-time-user="0"]:not([data-me-role="3"]) .t{display:none !important;}
#room[data-show-time-guest="0"][data-me-role="3"] .t{display:none !important;}

/* Embed mode styling */
body.embed-mode {
    background: white;
    height: 100%;
}

body.embed-mode .app-shell {
    min-height: 100%;
    flex-direction: column;
}

body.embed-mode .sidebar {
    display: none !important;
}

body.embed-mode .main-content {
    flex: 1;
    width: 100%;
    background: white;
    min-height: 100%;
}

body.embed-mode .container {
    max-width: 100%;
    padding: 12px;
    margin: 0;
    height: 100%;
}

body.embed-mode .admin-cards {
    grid-template-columns: 1fr;
    gap: 12px;
}

body.embed-mode .admin-card {
    margin-bottom: 0;
    box-shadow: none;
    border: none;
    padding: 0;
}

body.embed-mode .box {
    margin-bottom: 0;
    box-shadow: none;
    border: none;
    padding: 0;
}

body.embed-mode .djchat-window {
    height: 100vh;
    max-height: 100vh;
}

body.embed-mode .djchat-body {
    height: calc(100vh - 0px);
    display: flex;
    flex-direction: column;
    padding: 8px;
    gap: 8px;
}

body.embed-mode .djchat-header {
    display: none !important;
}

body.embed-mode .admin-note {
    display: none !important;
}

body.embed-mode .djchat-left {
    display: none !important;
}

body.embed-mode .sidebar {
    display: none !important;
}

@media (max-width: 900px) {
    body.embed-mode .djchat-header {
        display: none !important;
    }
    body.embed-mode .admin-note {
        display: none !important;
    }
}

body.embed-mode .djchat-center {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

body.embed-mode .djchat-center .djchat-log,
body.embed-mode .djchat-center #pm-chat-log {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
}

body.embed-mode .djchat-input-wrap {
    flex: 0 0 auto;
    position: sticky;
    bottom: 0;
    z-index: 2;
    background: #f7faff;
}

@media (max-width: 900px) {
    .sidebar { display: none !important; }
    .djchat-header { flex-direction: column; align-items: flex-start; gap: 10px; display: none; }
    .admin-note { display: none !important; }
    .djchat-header > div { width: 100%; }
    .djchat-body { display: flex; flex-direction: column; padding: 8px; gap: 8px; height: auto; }
    .djchat-left, .djchat-center { min-height: 0; width: 100%; }
    .djchat-left { display: none !important; }
    .djchat-center { display:flex; flex-direction:column; overflow: hidden; }
    .djchat-center .djchat-log, .djchat-center #pm-chat-log { flex: 1 1 auto; min-height: 220px; overflow:auto; }
    .djchat-left::-webkit-scrollbar, .djchat-center::-webkit-scrollbar { width: 8px; }
    .djchat-left::-webkit-scrollbar-thumb, .djchat-center::-webkit-scrollbar-thumb { background: rgba(14,36,71,.2); border-radius: 8px; }
    .djchat-room-actions, .djchat-users-filter, .djchat-form { flex-direction: column; align-items: stretch; }
    .djchat-room-actions { gap: 10px; }
    .djchat-users-filter { gap: 8px; }
    .djchat-users-filter .djbtn { min-width: auto; width: 100%; }
    .djchat-form .djbtn, .djchat-room-actions .djbtn, .btn { width: 100%; }
    .djchat-input, #chat-input, #dm-input { min-height: 48px; }
    .djchat-log, #chat-log, #dm-log { min-height: 240px; }
    .djchat-window { height: 100vh; max-height: 100vh; overflow: hidden; }
    .djchat-header-actions { width: 100%; justify-content: flex-start; flex-wrap: wrap; gap: 10px; }
    .djchat-room-name { font-size: 18px; }
    .djchat-panel-body, .djchat-users-filter, .djchat-room-actions, .djchat-log { padding: 8px; }
    .djchat-tabpanes, .djchat-pane, .djchat-panel-body { min-height: 0; }
    .djchat-panel-body { max-height: 260px; overflow:auto; }
    .djchat-tabs { flex-wrap: wrap; gap: 8px; }
    .djtab { flex: 1 1 48%; }
    .djchat-room-actions { width: 100%; }
    .djchat-input-wrap { padding: 10px; position: sticky; bottom: 0; background: #f7faff; z-index:2; }
    .djchat-toolbar { flex-wrap: wrap; gap: 8px; }
}

@media (max-width: 560px) {
    .sidebar { padding: 14px; }
    .sidebar-nav { gap: 6px; }
    .sidebar-nav a { padding: 10px 12px; font-size: 13px; }
    .container { padding: 12px; }
    .btn, .button, .djbtn { padding: 12px; min-height: 46px; }
    .djchat-header, .djchat-room-actions, .djchat-form { gap: 8px; }
    .djchat-title { font-size: 18px; }
    .djchat-room-name { font-size: 16px; }
    .djchat-log, #chat-log, #dm-log { min-height: 240px; }
    .djchat-input, #chat-input, #dm-input { padding: 10px; }
    .djchat-tabs { gap: 6px; }
    .djtab { flex: 1 1 100%; }
    .djchat-left { max-height: 320px; }
    .djchat-panel-body { max-height: 220px; }
}
