/* ======================================
   COMIRAINSTAL - Admin Panel PRO v2
   UI Stylesheet - Responsive & Modern
   ====================================== */

:root {
  /* Colors - Based on Comirainstal.ro identity */
  --bg1: #0a0f1c;
  --bg2: #0d1222;
  --panel: #0f172a;
  --text: #eaf2ff;
  --muted: #9fb3c8;
  --line: rgba(150, 164, 187, 0.2);
  --blue: #0ea5e9;
  --cyan: #22d3ee;
  --orange: #f59e0b;
  --green: #22c55e;
  --red: #ef4444;
  
  /* Layout */
  --sidebar-width: 70px;
  --topbar-height: 72px;
  
  /* Spacing */
  --gap: 16px;
  --gap-sm: 8px;
  --gap-lg: 24px;
  
  /* Border radius */
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
}

/* ========== RESET & BASE ========== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background: var(--bg1);
  color: var(--text);
  overflow: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
}

/* ========== LAYOUT ========== */
.wrap {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: var(--topbar-height) 1fr;
  grid-template-areas:
    "sidebar topbar"
    "sidebar main";
  height: 100vh;
}

/* ========== SIDEBAR ========== */
.sidebar {
  grid-area: sidebar;
  background: var(--bg2);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--gap) 0;
  position: relative;
  z-index: 100;
}

.brand {
  width: 54px;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--blue), var(--cyan));
  border-radius: var(--radius);
  font-size: 9px;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
  color: white;
  cursor: pointer;
  transition: transform 0.2s;
  margin-bottom: var(--gap-lg);
}

.brand:hover {
  transform: scale(1.05);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: var(--gap-sm);
  width: 100%;
  padding: 0 var(--gap-sm);
}

.nav a {
  width: 100%;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  position: relative;
  transition: all 0.2s;
  color: var(--muted);
}

.nav a svg {
  width: 20px;
  height: 20px;
}

.nav a:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

.nav a.active {
  background: var(--blue);
  color: white;
  box-shadow: 0 4px 12px rgba(14, 165, 233, 0.3);
}

.nav a .tip {
  position: absolute;
  left: calc(100% + 12px);
  background: var(--panel);
  color: var(--text);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translateX(-10px);
  transition: all 0.2s;
  border: 1px solid var(--line);
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.nav a:hover .tip {
  opacity: 1;
  transform: translateX(0);
}

.spacer {
  flex: 1;
}

.user {
  width: 100%;
  padding: 0 var(--gap-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--gap-sm);
}

.user-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--panel);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  border: 2px solid var(--line);
}

.user-name {
  font-size: 10px;
  color: var(--muted);
  text-align: center;
  max-width: 54px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pill, .logout-btn {
  width: 48px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: rgba(239, 68, 68, 0.1);
  color: var(--red);
  transition: all 0.2s;
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.pill:hover, .logout-btn:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.4);
}

.pill svg, .logout-btn svg {
  width: 18px;
  height: 18px;
}

/* ========== TOPBAR ========== */
.topbar {
  grid-area: topbar;
  background: var(--bg2);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--gap-lg);
  position: relative;
  z-index: 50;
}

.h1 h1 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 4px;
}

.h1 p {
  font-size: 14px;
  color: var(--muted);
}

.actions {
  display: flex;
  gap: var(--gap-sm);
}

/* ========== MAIN CONTENT ========== */
.main {
  grid-area: main;
  overflow-y: auto;
  padding: var(--gap-lg);
  background: var(--bg1);
}

#view {
  max-width: 1400px;
  margin: 0 auto;
}

/* ========== COMPONENTS ========== */

/* Panel */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--gap-lg);
  margin-bottom: var(--gap);
}

/* Card */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--gap);
  transition: all 0.2s;
}

.card:hover {
  border-color: rgba(150, 164, 187, 0.4);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

/* Grid layouts */
.grid2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: var(--gap);
}

/* Card content */
.card .k {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 8px;
}

.card .v {
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 4px;
}

.card .muted {
  font-size: 13px;
  color: var(--muted);
}

/* Badges */
.badge-ok { color: var(--green); }
.badge-warning { color: var(--orange); }
.badge-info { color: var(--cyan); }
.badge-error { color: var(--red); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(150, 164, 187, 0.4);
}

.btn.primary {
  background: var(--blue);
  border-color: var(--blue);
  color: white;
}

.btn.primary:hover {
  background: #0284c7;
  border-color: #0284c7;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

/* Input */
.input {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(15, 23, 42, 0.55);
  color: var(--text);
  font-size: 14px;
  transition: all 0.2s;
}

.input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
}

/* Form */
.form-section {
  margin-top: var(--gap);
}

.form-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text);
}

/* Row */
.row {
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
  flex-wrap: wrap;
}

/* Loading */
.loading {
  padding: var(--gap-lg);
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

.loading::before {
  content: "⏳ ";
}

/* Error */
.error {
  padding: var(--gap);
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-sm);
  color: var(--red);
  font-size: 14px;
}

/* Toast notifications */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--panel);
  color: var(--text);
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 9999;
  font-size: 14px;
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.3s;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.ok {
  border-color: var(--green);
  background: rgba(34, 197, 94, 0.1);
  color: var(--green);
}

.toast.error {
  border-color: var(--red);
  background: rgba(239, 68, 68, 0.1);
  color: var(--red);
}

.toast.info {
  border-color: var(--cyan);
  background: rgba(34, 211, 238, 0.1);
  color: var(--cyan);
}

/* ========== MODULE SPECIFIC STYLES ========== */

/* Activity list */
.activity-list {
  display: flex;
  flex-direction: column;
  gap: var(--gap-sm);
  margin-top: var(--gap);
}

.activity-item {
  display: flex;
  gap: var(--gap-sm);
  padding: var(--gap-sm);
  background: rgba(255, 255, 255, 0.02);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  transition: all 0.2s;
}

.activity-item:hover {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.04);
}

.activity-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg2);
  border-radius: var(--radius-sm);
  font-size: 16px;
}

.activity-content {
  flex: 1;
}

.activity-title {
  font-size: 14px;
  margin-bottom: 2px;
}

.activity-meta {
  font-size: 12px;
}

/* Pages grid */
.pages-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--gap);
}

.page-card {
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
}

.page-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg2);
  border-radius: var(--radius-sm);
  font-size: 20px;
}

.page-info {
  flex: 1;
  min-width: 0;
}

.page-title {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-path {
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-actions {
  display: flex;
  gap: var(--gap-sm);
}

/* Media grid */
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--gap);
}

.media-item {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.media-preview {
  width: 100%;
  height: 140px;
  background: var(--bg2);
  background-size: cover;
  background-position: center;
  border-radius: var(--radius-sm);
  margin-bottom: var(--gap-sm);
}

.media-info {
  flex: 1;
  min-width: 0;
}

.media-name {
  font-size: 13px;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.media-meta {
  font-size: 11px;
}

.media-actions {
  display: flex;
  gap: var(--gap-sm);
  margin-top: var(--gap-sm);
}

/* Services list */
.services-list {
  display: flex;
  flex-direction: column;
  gap: var(--gap-sm);
}

.service-card {
  display: flex;
  align-items: center;
  gap: var(--gap);
}

.service-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg2);
  border-radius: var(--radius-sm);
  font-size: 24px;
}

.service-info {
  flex: 1;
  min-width: 0;
}

.service-title {
  font-size: 16px;
  font-weight: 500;
  margin-bottom: 4px;
}

.service-desc {
  font-size: 13px;
  margin-bottom: 4px;
}

.service-meta {
  font-size: 12px;
}

.service-actions {
  display: flex;
  gap: var(--gap-sm);
}

/* Messages list */
.messages-list {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.message-card {
  display: flex;
  flex-direction: column;
  gap: var(--gap-sm);
  transition: all 0.2s;
}

.message-card.message-new {
  border-color: var(--orange);
  background: rgba(245, 158, 11, 0.05);
}

.message-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--gap-sm);
}

.message-from {
  flex: 1;
  font-size: 14px;
}

.message-status {
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.message-subject {
  font-size: 15px;
  font-weight: 500;
}

.message-content {
  font-size: 14px;
  line-height: 1.6;
  color: var(--muted);
}

.message-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--gap-sm);
  padding-top: var(--gap-sm);
  border-top: 1px solid var(--line);
}

.message-date {
  font-size: 12px;
}

.message-actions {
  display: flex;
  gap: var(--gap-sm);
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
  .wrap {
    grid-template-columns: 1fr;
    grid-template-rows: auto var(--topbar-height) 1fr;
    grid-template-areas:
      "sidebar"
      "topbar"
      "main";
  }
  
  .sidebar {
    flex-direction: row;
    width: 100%;
    height: auto;
    padding: var(--gap-sm) var(--gap);
    border-right: none;
    border-bottom: 1px solid var(--line);
    overflow-x: auto;
  }
  
  .brand {
    margin-bottom: 0;
    margin-right: var(--gap);
  }
  
  .nav {
    flex-direction: row;
    flex: 1;
    padding: 0;
  }
  
  .nav a .tip {
    display: none;
  }
  
  .spacer {
    display: none;
  }
  
  .user {
    flex-direction: row;
    width: auto;
    padding: 0;
  }
  
  .user-name {
    display: none;
  }
  
  .topbar {
    padding: 0 var(--gap);
  }
  
  .h1 h1 {
    font-size: 20px;
  }
  
  .h1 p {
    font-size: 12px;
  }
  
  .grid2 {
    grid-template-columns: 1fr;
  }
  
  .pages-grid,
  .media-grid {
    grid-template-columns: 1fr;
  }
}

/* ========== UTILITIES ========== */
.muted {
  color: var(--muted);
}

h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: var(--gap-sm);
}

h4 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: var(--gap-sm);
}

code {
  background: var(--bg2);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  font-family: 'Courier New', monospace;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg1);
}

::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(150, 164, 187, 0.4);
}


/* ===== Modal ===== */
.modal-backdrop{
  position:fixed; inset:0; background:rgba(0,0,0,.55);
  display:flex; align-items:center; justify-content:center; z-index:9999;
  padding:18px;
}
.modal{
  width:min(920px, 96vw);
  max-height:90vh;
  background:rgba(18,24,38,.98);
  border:1px solid rgba(255,255,255,.08);
  border-radius:16px;
  box-shadow:0 20px 80px rgba(0,0,0,.55);
  overflow:hidden;
}
.modal-head{
  display:flex; align-items:center; justify-content:space-between;
  padding:14px 16px;
  border-bottom:1px solid rgba(255,255,255,.08);
}
.modal-title{ font-weight:700; }
.modal-close{
  border:0; background:transparent; color:inherit; font-size:18px; cursor:pointer;
  padding:6px 10px; border-radius:10px;
}
.modal-close:hover{ background:rgba(255,255,255,.06); }
.modal-body{ padding:16px; overflow:auto; max-height:65vh; }
.modal-foot{
  padding:12px 16px;
  border-top:1px solid rgba(255,255,255,.08);
  display:flex; gap:10px; justify-content:flex-end;
}
.lbl{ display:block; font-size:12px; letter-spacing:.02em; opacity:.85; margin-bottom:6px; }

/* ===== Editor ===== */
.editor-toolbar{
  display:flex; flex-wrap:wrap; gap:8px; align-items:center;
  padding:10px;
  border:1px solid rgba(255,255,255,.08);
  border-radius:14px;
  background:rgba(255,255,255,.03);
}
.editor-toolbar .sep{ width:1px; height:22px; background:rgba(255,255,255,.12); margin:0 6px; }
.editor-area{
  margin-top:12px;
  border:1px solid rgba(255,255,255,.08);
  border-radius:14px;
  background:rgba(0,0,0,.12);
  overflow:hidden;
}
.wysiwyg{
  min-height:48vh;
  padding:18px;
  outline:none;
}
.wysiwyg:focus{ box-shadow:inset 0 0 0 2px rgba(14,165,233,.35); }

/* ===== Media Picker ===== */
.mp-grid{
  display:grid;
  grid-template-columns:repeat(auto-fill, minmax(140px, 1fr));
  gap:12px;
}
.mp-item{
  display:flex; flex-direction:column;
  gap:8px;
  border:1px solid rgba(255,255,255,.08);
  background:rgba(255,255,255,.03);
  border-radius:14px;
  padding:10px;
  cursor:pointer;
  text-align:left;
}
.mp-item:hover{ border-color:rgba(14,165,233,.45); }
.mp-item img{ width:100%; height:92px; object-fit:cover; border-radius:10px; }
.mp-cap{ font-size:12px; opacity:.9; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }

/* ===== Revisions ===== */
.rev-list{ display:flex; flex-direction:column; gap:10px; }
.rev-row{
  display:flex; align-items:center; justify-content:space-between;
  gap:12px;
  border:1px solid rgba(255,255,255,.08);
  border-radius:14px;
  padding:10px 12px;
  background:rgba(255,255,255,.03);
}
.rev-id{ font-weight:700; }

.btn.danger, .btn.btn-sm.danger{
  background:rgba(239,68,68,.12);
  border-color:rgba(239,68,68,.35);
}
.btn.danger:hover{ background:rgba(239,68,68,.18); }
