/* ===== Base ===== */
*{box-sizing:border-box}
body, input, select, button, textarea {
  font-family:'CustomFont',sans-serif;
  margin:0;
  padding:0;
  background:#0f1115;
  color:#e5e7eb;
}

/* ===== Header ===== */
.topbar{
  display:flex;
  justify-content:space-between;
  align-items:center;
  background:#0b0d12;
  padding:15px 20px;
  border-bottom:1px solid #1f2937;
  position:sticky;
  top:0;
  z-index:101;
}
.logo{font-size:24px;font-weight:bold;color:#38bdf8}
.tagline{font-size:14px;color:#aaa}
.menu-toggle{font-size:24px;cursor:pointer;display:none;color:#38bdf8}

/* ===== Layout ===== */
.layout{display:flex;min-height:calc(100vh - 60px)}

/* ===== Sidebar ===== */
.sidebar{
  width:220px;
  background:#111318;
  padding:20px;
  display:flex;
  flex-direction:column;
  gap:10px;
  position:fixed;
  top:0;
  right:-100%;
  height:100%;
  transition:right 0.3s ease;
  z-index:102;
}
.sidebar.active{right:0}
.sidebar button{
  padding:10px;
  background:#1f2937;
  border:none;
  color:#e5e7eb;
  font-size:16px;
  cursor:pointer;
  border-radius:6px;
  transition: all 0.2s;
}
.sidebar button:hover{background:#374151; transform: translateX(-2px);}
.sidebar button:active{transform: translateX(0);}

/* ===== إضافة أنماط نظام المصادقة ===== */
.auth-section { 
  margin-top: auto; 
  display: flex; 
  flex-direction: column; 
  gap: 10px; 
}
.user-info { 
  padding: 15px; 
  background: #1f2937; 
  border-radius: 6px; 
  text-align: center; 
  margin-top: auto; 
  border: 1px solid #374151;
}
.user-info p { 
  margin: 0; 
  color: #38bdf8; 
  font-weight: bold; 
  margin-bottom: 5px; 
  cursor: pointer;
  transition: color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
.user-info p:hover { 
  color: #0ea5e9; 
}
.user-info small {
  color: #9ca3af;
  font-size: 12px;
  display: block;
  margin-bottom: 10px;
}
.logout-btn { 
  width: 100%; 
  padding: 8px; 
  background: #ef4444; 
  color: white; 
  border: none; 
  border-radius: 4px; 
  cursor: pointer; 
  font-size: 14px; 
  transition: background 0.2s, transform 0.1s;
}
.logout-btn:hover { 
  background: #dc2626; 
}
.logout-btn:active {
  transform: scale(0.98);
}
.auth-btn { 
  width: 100%; 
  padding: 10px; 
  background: #1f2937; 
  border: none; 
  color: #e5e7eb; 
  font-size: 16px; 
  cursor: pointer; 
  border-radius: 6px; 
  text-align: center; 
  transition: background 0.2s, transform 0.1s;
}
.auth-btn:hover { 
  background: #374151; 
  transform: translateY(-2px);
}
.auth-btn:active {
  transform: translateY(0);
}

/* ===== أنماط نظام الملف الشخصي ===== */
.seller-link {
  color: #38bdf8;
  cursor: pointer;
  text-decoration: underline;
  transition: color 0.2s;
  position: relative;
}
.seller-link:hover {
  color: #0ea5e9;
  text-decoration: none;
}
.seller-link::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 1px;
  background: #0ea5e9;
  transition: width 0.2s;
}
.seller-link:hover::after {
  width: 100%;
}
.profile-link {
  color: #38bdf8;
  cursor: pointer;
  transition: color 0.2s;
}
.profile-link:hover {
  color: #0ea5e9;
}

/* ===== Overlay ===== */
.overlay{
  position:fixed;
  top:0;
  left:0;
  width:100%;
  height:100%;
  background: rgba(0,0,0,0.4);
  display:none;
  z-index:101;
  backdrop-filter: blur(2px);
}
.overlay.active{display:block}

/* ===== Main Content ===== */
main{flex:1;padding:20px;overflow:auto;margin-left:0}

/* ===== Search Bar ===== */
.search-bar{display:flex;gap:10px;flex-wrap:wrap;margin-bottom:20px}
.search-bar input,.search-bar select{
  flex:1;
  padding:10px;
  border-radius:6px;
  border:none;
  background:#1f2937;
  color:#e5e7eb;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.search-bar input:focus,.search-bar select:focus{
  outline:none;
  border-color:#38bdf8;
  box-shadow:0 0 0 2px rgba(56, 189, 248, 0.2);
}
.search-bar .budget-btn{
  background:#1f2937;
  color:#e5e7eb;
  border:none;
  padding:10px 15px;
  border-radius:6px;
  cursor:pointer;
  transition: background 0.2s, transform 0.1s;
}
.search-bar .budget-btn:hover{background:#374151; transform: translateY(-2px);}
.search-bar .budget-btn:active{transform: translateY(0);}

/* ===== Cards ===== */
.cards{display:grid;grid-template-columns:1fr;gap:15px}
@media(min-width:600px){.cards{grid-template-columns:1fr 1fr}}
@media(min-width:900px){.cards{grid-template-columns:1fr 1fr 1fr}}
.card{
  background:#1c1f27;
  padding:15px;
  border-radius:8px;
  display:flex;
  flex-direction:column;
  gap:8px;
  box-shadow:0 2px 6px rgba(0,0,0,0.3);
  transition: transform 0.2s, box-shadow 0.2s;
  cursor:pointer;
  border: 1px solid #2d3748;
  position: relative;
  overflow: hidden;
}
.card:hover{
  transform: translateY(-3px);
  box-shadow:0 8px 16px rgba(0,0,0,0.4);
  border-color: #38bdf8;
}
.card:active{
  transform: translateY(-1px);
}
.card h3{margin:0;font-size:18px;color:#38bdf8; line-height:1.4;}
.card .price{font-weight:bold;color:#38bdf8;font-size:16px}
.card .meta,.card .seller{
  font-size:13px;
  color:#aaa;
  display:flex;
  justify-content:space-between;
  flex-wrap:wrap;
  gap:5px;
}
.card .seller {
  background: rgba(56, 189, 248, 0.1);
  padding: 8px;
  border-radius: 4px;
  margin-top: 5px;
  border-left: 3px solid #38bdf8;
}
.card .actions{
  display:flex;
  gap:10px;
  justify-content:flex-end;
  margin-top:10px;
  opacity: 0;
  transition: opacity 0.2s;
}
.card:hover .actions{
  opacity: 1;
}
.card .actions button{
  padding:6px 10px;
  border:none;
  border-radius:6px;
  cursor:pointer;
  font-size:13px;
  transition: all 0.2s;
  min-width: 60px;
}
.card .actions .edit{
  background:#10b981;
  color:#fff;
}
.card .actions .edit:hover{
  background:#0da271;
  transform: translateY(-1px);
}
.card .actions .edit:active{
  transform: translateY(0);
}
.card .actions .del{
  background:#ef4444;
  color:#fff;
}
.card .actions .del:hover{
  background:#dc2626;
  transform: translateY(-1px);
}
.card .actions .del:active{
  transform: translateY(0);
}

/* ===== Form Box ===== */
.form-box{
  background:#1c1f27;
  padding:20px;
  border-radius:8px;
  max-width:500px;
  margin:auto;
  display:flex;
  flex-direction:column;
  gap:10px;
  border: 1px solid #374151;
}
.form-box h2{
  color:#38bdf8;
  margin-bottom:15px;
  text-align:center;
  border-bottom:1px solid #374151;
  padding-bottom:10px;
}
.form-box input,.form-box select{
  padding:10px;
  border-radius:6px;
  border:1px solid #374151;
  background:#111318;
  color:#e5e7eb;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.form-box input:focus,.form-box select:focus{
  outline:none;
  border-color:#38bdf8;
  box-shadow:0 0 0 2px rgba(56, 189, 248, 0.2);
}
.form-box button{
  background:#38bdf8;
  color:#000;
  cursor:pointer;
  padding:10px;
  border-radius:6px;
  border:none;
  font-weight:bold;
  transition:background 0.2s, transform 0.1s;
}
.form-box button:hover{
  background:#0ea5e9;
  transform: translateY(-2px);
}
.form-box button:active{
  transform: translateY(0);
}
.form-box button:disabled{
  background:#4b5563;
  cursor:not-allowed;
  transform: none;
}

/* ===== Empty State ===== */
.empty{
  text-align:center;
  margin-top:30px;
  color:#aaa;
  font-size:16px;
  grid-column:1/-1;
  padding: 30px;
  background: rgba(31, 41, 55, 0.3);
  border-radius: 8px;
  border: 1px dashed #374151;
}

/* ===== Budget Dialog ===== */
.budget-dialog {
  position:fixed;
  top:50%;
  left:50%;
  transform:translate(-50%,-50%);
  background:#0f1115;
  color:#e5e7eb;
  padding:20px;
  border-radius:10px;
  box-shadow:0 0 15px rgba(0,0,0,0.5);
  z-index:103;
  display:none;
  opacity:0;
  transition: opacity 0.3s ease;
  border: 1px solid #374151;
  max-width: 400px;
  width: 90%;
}
.budget-dialog.show{
  display:block;
  opacity:1;
}
.budget-dialog input {
  width:100%;
  padding:10px;
  margin:10px 0;
  border-radius:6px;
  border:1px solid #333;
  background:#1f1f1f;
  color:#e5e7eb;
  transition: border-color 0.2s;
}
.budget-dialog input:focus{
  outline:none;
  border-color:#38bdf8;
}
.budget-dialog button{
  padding:8px 12px;
  border:none;
  border-radius:6px;
  cursor:pointer;
  font-weight:bold;
  transition: all 0.2s;
  min-width: 80px;
}
.budget-dialog button:not(.close-btn){
  background:#38bdf8;
  color:#000;
}
.budget-dialog button:not(.close-btn):hover{
  background:#0ea5e9;
  transform: translateY(-1px);
}
.budget-dialog button:not(.close-btn):active{
  transform: translateY(0);
}
.budget-dialog .close-btn{
  background:#ef4444;
  margin-left:10px;
  color:#fff;
}
.budget-dialog .close-btn:hover{
  background:#dc2626;
  transform: translateY(-1px);
}
.budget-dialog .close-btn:active{
  transform: translateY(0);
}

/* ===== Pagination ===== */
#pagination{
  display:flex;
  justify-content:center;
  flex-wrap:wrap;
  gap:5px;
  margin-top:20px;
}
#pagination button{
  padding:6px 10px;
  border-radius:6px;
  border:none;
  cursor:pointer;
  font-weight:bold;
  background:#1f2937;
  color:#e5e7eb;
  transition: all 0.2s;
  min-width: 40px;
}
#pagination button:hover{
  background:#38bdf8;
  color:#000;
  transform: translateY(-2px);
}
#pagination button.active{
  background:#38bdf8;
  color:#000;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}
#pagination button:active{
  transform: translateY(0);
}
@media(max-width:500px){
  #pagination button{
    padding:5px 8px;
    font-size:13px;
    min-width: 35px;
  }
}

/* ===== تحسينات الأمان والإضافات ===== */
.verified-badge {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 10px;
  margin-right: 5px;
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.admin-badge {
  background: linear-gradient(135deg, #8b5cf6, #7c3aed);
  color: white;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 10px;
  margin-right: 5px;
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.product-status {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 4px;
  margin-top: 5px;
  display: inline-block;
  font-weight: bold;
  text-align: center;
  min-width: 60px;
}

.status-available { 
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(5, 150, 105, 0.2)); 
  color: #10b981; 
  border: 1px solid rgba(16, 185, 129, 0.3);
}
.status-sold { 
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.2), rgba(220, 38, 38, 0.2)); 
  color: #ef4444; 
  border: 1px solid rgba(239, 68, 68, 0.3);
}
.status-reserved { 
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.2), rgba(217, 119, 6, 0.2)); 
  color: #f59e0b; 
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.security-warning {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.1), rgba(220, 38, 38, 0.1));
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #ef4444;
  padding: 12px;
  border-radius: 6px;
  margin: 10px 0;
  font-size: 13px;
  text-align: center;
  animation: slideIn 0.3s ease;
  box-shadow: 0 2px 4px rgba(239, 68, 68, 0.1);
}

.security-success {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(5, 150, 105, 0.1));
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #10b981;
  padding: 12px;
  border-radius: 6px;
  margin: 10px 0;
  font-size: 13px;
  text-align: center;
  animation: slideIn 0.3s ease;
  box-shadow: 0 2px 4px rgba(16, 185, 129, 0.1);
}

.security-info {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.1), rgba(14, 165, 233, 0.1));
  border: 1px solid rgba(56, 189, 248, 0.3);
  color: #38bdf8;
  padding: 12px;
  border-radius: 6px;
  margin: 10px 0;
  font-size: 13px;
  text-align: center;
  animation: slideIn 0.3s ease;
  box-shadow: 0 2px 4px rgba(56, 189, 248, 0.1);
}

.session-timeout {
  position: fixed;
  top: 20px;
  right: 20px;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.95), rgba(217, 119, 6, 0.95));
  color: #000;
  padding: 15px;
  border-radius: 8px;
  z-index: 2000;
  display: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  animation: pulse 2s infinite;
  border: 1px solid rgba(245, 158, 11, 0.5);
  min-width: 300px;
}

/* ===== Animations ===== */
@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4);
  }
  50% {
    box-shadow: 0 0 0 10px rgba(245, 158, 11, 0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ===== تحسينات عامة ===== */
input:invalid, select:invalid {
  border-color: #ef4444 !important;
}

input:valid, select:valid {
  border-color: #10b981 !important;
}

::selection {
  background: rgba(56, 189, 248, 0.3);
  color: #e5e7eb;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #1f2937;
}

::-webkit-scrollbar-thumb {
  background: #374151;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #4b5563;
}

/* ===== Product Details Dialog ===== */
.details-dialog {
  position:fixed;
  top:50%;
  left:50%;
  transform:translate(-50%,-50%);
  background:#1c1f27;
  padding:25px;
  border-radius:12px;
  box-shadow:0 0 20px rgba(0,0,0,0.5);
  color:#e5e7eb;
  z-index:104;
  display:none;
  max-width:450px;
  width:90%;
  animation: fadeIn 0.3s ease;
  border: 1px solid #374151;
}
.details-dialog h2 {
  color:#38bdf8;
  margin-bottom:15px;
  border-bottom:2px solid #374151;
  padding-bottom:15px;
  font-size:22px;
}
.details-dialog p {
  margin:10px 0;
  font-size:14px;
  line-height:1.6;
}
.details-dialog p strong {
  color: #9ca3af;
  display: inline-block;
  width: 90px;
  font-weight: 600;
}
.details-dialog button {
  margin-top:20px;
  padding:12px 20px;
  border:none;
  border-radius:8px;
  cursor:pointer;
  background:linear-gradient(135deg, #38bdf8, #0ea5e9);
  color:#000;
  font-weight:bold;
  width:100%;
  transition: all 0.2s;
  font-size:16px;
}
.details-dialog button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(56, 189, 248, 0.3);
}
.details-dialog button:active {
  transform: translateY(0);
}

/* ===== Responsive ===== */
@media(max-width:768px){
  .layout{flex-direction:column}
  .sidebar{
    top:60px;
    right:-100%;
    height:calc(100% - 60px);
    width:250px;
  }
  .menu-toggle{display:block}
  main{margin-left:0; padding:15px;}
  .overlay{display:none}
  .search-bar{
    flex-direction:column;
    gap: 10px;
  }
  .search-bar input,
  .search-bar select{
    width:100%;
  }
  .search-bar .budget-btn {
    width: 100%;
  }
  .cards{
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .card{
    padding: 12px;
  }
  .form-box{
    padding: 15px;
  }
  .session-timeout {
    top: 10px;
    right: 10px;
    left: 10px;
    min-width: auto;
    width: calc(100% - 20px);
  }
}
@media(min-width:768px){
  .sidebar{position:relative;right:0}
  main{margin-left:220px}
  .overlay{display:none !important}
}

@media(min-width:1200px){
  main{
    max-width: 1400px;
    margin-left: auto;
    margin-right: auto;
  }
}

/* ===== تحسينات للأجهزة اللوحية ===== */
@media(min-width:600px) and (max-width:900px){
  .cards{
    grid-template-columns: repeat(2, 1fr);
  }
  .card h3{
    font-size: 16px;
  }
}

/* ===== تحسينات الطباعة ===== */
@media print {
  .sidebar,
  .topbar,
  .search-bar,
  .actions,
  .auth-section,
  .session-timeout,
  .budget-dialog,
  .details-dialog,
  .overlay {
    display: none !important;
  }
  
  main {
    margin-left: 0 !important;
    padding: 0 !important;
  }
  
  .card {
    break-inside: avoid;
    border: 1px solid #000 !important;
    box-shadow: none !important;
  }
}

/* ===== تحسينات للأداء ===== */
* {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, svg {
  max-width: 100%;
  height: auto;
}

/* ===== تحسينات لضعاف البصر ===== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ===== تحسينات للوضع الداكن الإضافي ===== */
@media (prefers-color-scheme: dark) {
  body {
    background: #0f1115;
  }
}

/* ===== تحسينات لشاشات عالية الدقة ===== */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  body {
    -webkit-font-smoothing: subpixel-antialiased;
  }
}

/* ===== تحسينات لحجم الخط ===== */
@media (max-width: 360px) {
  html {
    font-size: 14px;
  }
}
