/*
  Masrofy – Base UI (Theme + Layout)
  - Used by header/footer (partials) and standalone pages.
  - Works with :root[data-theme="light|dark"] and :root[dir="rtl|ltr"].
*/

:root{
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f3f4f6;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --shadow: 0 10px 30px rgba(0,0,0,.08);

  --primary: #208f8f;
  --primary-2: #0f5656;
  --danger: #b91c1c;
  --warning: #b45309;
  --success: #065f46;

  --radius: 14px;
  --radius-sm: 10px;
  --container: 1180px;
}

:root[data-theme="dark"]{
  --bg: #0b1220;
  --surface: #0f1a2d;
  --surface-2: #0b1526;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --border: #22304a;
  --shadow: 0 12px 30px rgba(0,0,0,.35);
}

/* --- Resets --- */
*{box-sizing:border-box}
html,body{height:100%}
body.ms-ui{margin:0;font-family:system-ui,-apple-system,"Segoe UI",Tahoma,Arial,sans-serif;background:var(--bg);color:var(--text)}
img{max-width:100%;height:auto}
a{color:inherit}

/* --- App shell --- */
.ms-ui .app-shell{min-height:100vh;display:flex;flex-direction:column}
.ms-ui .app-main{flex:1;max-width:var(--container);width:100%;margin:0 auto;padding:18px 14px 26px}

/* --- Topbar --- */
.ms-ui .topbar{position:sticky;top:0;z-index:1000;background:linear-gradient(135deg,var(--primary) 0%, var(--primary-2) 100%);color:#fff;border-bottom:1px solid rgba(255,255,255,.15)}
.ms-ui .topbar-inner{max-width:var(--container);margin:0 auto;padding:12px 14px;display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap}
.ms-ui .brand{display:flex;align-items:center;gap:10px;min-width:240px}
.ms-ui .brand img{height:56px;width:auto;max-width:220px;border-radius:14px;object-fit:contain;background:rgba(255,255,255,.12);border:1px solid rgba(255,255,255,.22)}
.ms-ui .brand .title{display:flex;flex-direction:column;line-height:1.1}
.ms-ui .brand .name{font-weight:900;font-size:16px}
.ms-ui .brand .sub{font-size:12px;opacity:.88}

.ms-ui .topbar-actions{display:flex;align-items:center;gap:8px;flex-wrap:wrap}

/* --- Buttons --- */
.ms-ui .btn{display:inline-flex;align-items:center;justify-content:center;gap:8px;padding:9px 12px;border-radius:999px;border:1px solid var(--border);background:var(--surface);color:var(--text);text-decoration:none;cursor:pointer;font-weight:700;font-size:13px;line-height:1}
.ms-ui .btn:hover{filter:brightness(0.98)}
.ms-ui .btn:active{transform:translateY(1px)}
.ms-ui .btn-small{padding:7px 10px;font-size:12px}

.ms-ui .btn-primary{background:#fff;border-color:rgba(255,255,255,.25);color:#0f5656}
.ms-ui .btn-primary:hover{filter:brightness(.98)}

.ms-ui .btn-solid{background:var(--primary);border-color:rgba(0,0,0,.08);color:#fff}
.ms-ui .btn-solid:hover{background:var(--primary-2)}

.ms-ui .btn-secondary{background:var(--surface-2)}
.ms-ui .btn-danger{background:rgba(185,28,28,.12);border-color:rgba(185,28,28,.35);color:var(--danger)}

.ms-ui .badge{display:inline-flex;align-items:center;justify-content:center;padding:2px 10px;border-radius:999px;border:1px solid rgba(255,255,255,.25);background:rgba(255,255,255,.18);color:#fff;font-weight:800;font-size:12px}

/* --- Dropdown --- */
.dropdown{position:relative;display:inline-block}
.dropdown .btn{border-color:rgba(255,255,255,.25);background:rgba(255,255,255,.12);color:#fff}
.dropdown .btn:hover{background:rgba(255,255,255,.18)}
.dropdown-menu{display:none;position:absolute;top:calc(100% + 8px);right:0;min-width:180px;background:var(--surface);border:1px solid var(--border);border-radius:14px;box-shadow:var(--shadow);z-index:999;padding:6px}
.dropdown.open .dropdown-menu{display:block}
.dropdown-menu a,.dropdown-menu button{width:100%;display:block;text-align:right;padding:10px 12px;border:0;background:transparent;color:var(--text);cursor:pointer;border-radius:12px;font-weight:700;font-size:13px;text-decoration:none}
.dropdown-menu a:hover,.dropdown-menu button:hover{background:rgba(0,0,0,.05)}
:root[data-theme="dark"] .dropdown-menu a:hover,:root[data-theme="dark"] .dropdown-menu button:hover{background:rgba(255,255,255,.06)}

:root[dir="ltr"] .dropdown-menu{right:auto;left:0}
:root[dir="ltr"] .dropdown-menu a,:root[dir="ltr"] .dropdown-menu button{text-align:left}

/* --- Forms --- */
.ms-ui .input, .ms-ui input[type="text"], .ms-ui input[type="password"], .ms-ui input[type="email"], .ms-ui input[type="url"], .ms-ui input[type="number"], .ms-ui select, .ms-ui textarea{
  width:100%;
  padding:10px 12px;
  border-radius:12px;
  border:1px solid var(--border);
  background:var(--surface);
  color:var(--text);
  outline:none;
  font-size:14px;
}
.ms-ui textarea{min-height:110px;resize:vertical}
.ms-ui input:focus, .ms-ui select:focus, .ms-ui textarea:focus{border-color:rgba(32,143,143,.55);box-shadow:0 0 0 3px rgba(32,143,143,.18)}
.ms-ui .help-text, .ms-ui .small{color:var(--muted);font-size:12px}
.ms-ui label{display:block;margin-bottom:6px;font-size:13px;font-weight:800}

/* --- Cards --- */
.ms-ui .container{max-width:var(--container);margin:0 auto;padding:0 14px}
.ms-ui .card{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);box-shadow:var(--shadow)}
.ms-ui .card + .card{margin-top:14px}
.ms-ui .card-header{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:14px 14px;border-bottom:1px solid var(--border)}
.ms-ui .card-body{padding:14px 14px}
.ms-ui .card-title{font-weight:900;margin:0;font-size:16px}

/* --- Tables --- */
.ms-ui table{width:100%;border-collapse:collapse}
.ms-ui th, .ms-ui td{padding:10px 8px;border-bottom:1px solid var(--border);font-size:14px;text-align:right;vertical-align:middle}
.ms-ui th{color:var(--muted);font-size:12px}
:root[dir="ltr"] .ms-ui th,:root[dir="ltr"] .ms-ui td{text-align:left}

/* --- Footer --- */
.ms-ui .footer{margin-top:auto;border-top:1px solid var(--border);background:var(--surface)}
.ms-ui .footer .inner{max-width:var(--container);margin:0 auto;padding:12px 14px;display:flex;align-items:center;justify-content:center;gap:12px;flex-wrap:wrap}


/* --- Auth pages --- */
.ms-ui .auth-wrap{display:flex;align-items:center;justify-content:center;min-height:calc(100vh - 110px);padding:18px 14px}
.ms-ui .auth-card{width:100%;max-width:440px}
.ms-ui .auth-card .card-body{padding:18px}
.ms-ui .auth-title{font-weight:1000;font-size:20px;margin:0 0 8px}
.ms-ui .alert{padding:10px 12px;border-radius:12px;border:1px solid var(--border);background:var(--surface-2);color:var(--text);font-size:13px;margin-bottom:12px}
.ms-ui .alert.error{border-color:rgba(185,28,28,.35);background:rgba(185,28,28,.10);color:var(--danger)}
.ms-ui .alert.success{border-color:rgba(6,95,70,.35);background:rgba(6,95,70,.12);color:var(--success)}

/* Utility */
.ms-ui .row{display:flex;gap:10px;flex-wrap:wrap}
.ms-ui .row > *{flex:1}
.ms-ui .pill{display:inline-flex;align-items:center;justify-content:center;padding:2px 10px;border-radius:999px;background:var(--surface-2);border:1px solid var(--border);font-size:12px}


/* --- Brand (Name + Tagline) --- */
.ms-ui .brand .name{font-weight:1000;font-size:18px;letter-spacing:.2px}
.ms-ui .brand .tagline{font-size:12px;opacity:.92;font-weight:800;line-height:1.15;max-width:520px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
@media(max-width:640px){.ms-ui .brand img{height:46px;max-width:180px}.ms-ui .brand .name{font-size:16px}.ms-ui .brand .tagline{max-width:240px}}

/* Screen reader only */
.sr-only{position:absolute !important;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}

/* Icon buttons (theme/lang/profile) */
.ms-ui .btn.btn-icon{padding:10px 14px;border-radius:999px;display:inline-flex;align-items:center;gap:8px}
.ms-ui .btn.btn-icon .icon{font-size:16px;line-height:1}
.ms-ui .btn.btn-icon .badge{margin-inline-start:0}
.ms-ui .btn.btn-icon .btn-label{font-weight:950;font-size:12px;opacity:.95}
@media(max-width:720px){.ms-ui .btn.btn-icon .btn-label{display:none}}

/* Shimmer text (subtle highlight) */
.shimmer-text{position:relative;display:inline-block;background:linear-gradient(90deg, rgba(255,255,255,.75) 0%, #ffffff 45%, rgba(255,255,255,.75) 100%);-webkit-background-clip:text;background-clip:text;color:transparent;background-size:200% 100%;animation:masrofy_shimmer 3.2s ease-in-out infinite}
.shimmer-soft{position:relative;display:inline-block;background:linear-gradient(90deg, rgba(255,255,255,.55) 0%, rgba(255,255,255,.95) 45%, rgba(255,255,255,.55) 100%);-webkit-background-clip:text;background-clip:text;color:transparent;background-size:200% 100%;animation:masrofy_shimmer 3.8s ease-in-out infinite}
@keyframes masrofy_shimmer{0%{background-position:200% 0}100%{background-position:-200% 0}}

/* Landing/Auth background + footer style */
body.landing, body.auth{background:linear-gradient(135deg,var(--primary) 0%, var(--primary-2) 100%)}
body.landing .app-shell, body.auth .app-shell{background:transparent}
body.auth .app-main{max-width:var(--container)}
body.auth .auth-card{background:rgba(255,255,255,.96)}
body.auth .footer, body.landing .footer{background:transparent;border-top:1px solid rgba(255,255,255,.18)}
body.auth .footer .inner, body.landing .footer .inner{justify-content:center;text-align:center;color:rgba(255,255,255,.92)}
body.auth .footer .inner .small, body.landing .footer .inner .small{color:rgba(255,255,255,.92)}


/* === Masrofy UI Enhancements (patch) === */

/* Language/Theme buttons */
.topbar-actions.stacked-actions{flex-direction:row; gap:10px; align-items:center;}
@media (max-width: 720px){
  .topbar-actions.stacked-actions{flex-direction:column; gap:8px; align-items:flex-start;}
}
.topbar-actions.stacked-actions .btn{min-width:auto}

/* Compact brand for dashboard */
.brand.compact img{height:44px; width:auto; border-radius:14px;}
.brand.compact .name{font-size:18px;}
.brand.compact .tagline{font-size:12px; opacity:.9;}

/* Public/minimal header: hide brand & user items */
.topbar.minimal .brand{display:none;}
.topbar.minimal .dropdown#userDd{display:none;}

/* Footer more readable */
.footer .inner{font-size:13px;}

/* Bigger hero logo on landing */
.hero-logo img{max-height:120px; filter: drop-shadow(0 10px 25px rgba(0,0,0,.25));}
.hero-logo .brand-name{font-size:48px;}
.hero-logo .tagline{font-size:18px;}

/* Dashboard header layout helpers */
.dash-actions{display:flex; align-items:center; gap:10px; flex-wrap:wrap; justify-content:flex-end;}
.user-btn{display:flex; align-items:center; gap:10px; padding:8px 12px;}
.user-btn .avatar{width:34px; height:34px; border-radius:50%; object-fit:cover; border:2px solid var(--border);}
.user-btn .uname{font-weight:800; font-size:13px; line-height:1.1;}
.user-btn .role{font-size:12px; opacity:.85;}

/* Keep header from getting crowded on small screens */
@media (max-width: 900px){
  .topbar-inner{flex-wrap:wrap; gap:10px;}
  .dash-actions{width:100%; justify-content:space-between;}
}



/* === UI polish: compact topbar + mini icon controls === */
.ms-ui .topbar-inner{position:relative; padding-inline-start:64px; padding-inline-end:14px; flex-wrap:nowrap}
@media (max-width: 860px){ .ms-ui .topbar-inner{flex-wrap:wrap; padding-inline-start:54px;} }

.ms-ui .mini-controls{
  position:absolute;
  inset-inline-start:10px;
  top:10px;
  display:flex;
  flex-direction:column;
  gap:8px;
  z-index:2;
}
.ms-ui .icon-btn{
  width:34px;height:34px;
  border:0;
  background:transparent;
  color:#fff;
  opacity:.92;
  border-radius:10px;
  cursor:pointer;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:16px;
  line-height:1;
}
.ms-ui .icon-btn:hover{background:rgba(255,255,255,.16);opacity:1}
.ms-ui .icon-btn:active{transform:translateY(1px)}

.ms-ui .brand{min-width:unset; flex:1 1 auto}
.ms-ui .brand img{height:44px; max-width:120px; border-radius:12px; padding:0; box-shadow:none}
.ms-ui .brand .name{font-size:16px}
.ms-ui .brand .tagline{max-width:520px; opacity:.92}
@media (max-width: 860px){ .ms-ui .brand .tagline{display:none;} }

/* Force brand title readable on topbar (pages.php has old #appTitle styles) */
.ms-ui .topbar #appTitle{color:#fff !important; text-shadow:0 2px 10px rgba(0,0,0,.22) !important; animation:none !important; background:transparent !important}
.ms-ui .topbar #appTitle:hover{transform:none !important}
.ms-ui .topbar #appTagline{color:rgba(255,255,255,.92) !important; text-shadow:0 1px 8px rgba(0,0,0,.18) !important}

/* Context bar (group selector) */
.ms-ui .context-bar{max-width:var(--container); margin:12px auto 8px; padding:0 14px}
.ms-ui .context-inner{
  background:rgba(255,255,255,.60);
  border:1px solid var(--border);
  box-shadow:var(--shadow);
  border-radius:16px;
  padding:10px 12px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
:root[data-theme="dark"] .ms-ui .context-inner{background:rgba(15,26,45,.55)}
.ms-ui .group-switcher{display:flex; align-items:center; gap:10px; flex-wrap:wrap}
.ms-ui .group-select{min-width:260px; max-width:520px}
.ms-ui .group-label{font-weight:900;color:var(--text)}
@media (max-width: 640px){
  .ms-ui .context-inner{flex-direction:column; align-items:stretch}
  .ms-ui .group-select{min-width:0; width:100%; max-width:none}
}

/* Footer visibility */
.ms-ui .footer{background:var(--surface); border-top:1px solid var(--border)}
.ms-ui .footer .inner{color:rgba(17,24,39,.70); font-weight:800; font-size:13px}
:root[data-theme="dark"] .ms-ui .footer .inner{color:rgba(229,231,235,.72)}


/* Disable old logo hover/rotate effects from pages.php */
.ms-ui .topbar #appLogo{padding:0 !important; box-shadow:none !important; filter:none !important}
.ms-ui .topbar #appLogo:hover{transform:none !important; filter:none !important; box-shadow:none !important}
