/**
 * Medical Plan Analyzer - Styles
 * قارئ المخططات الطبية
 */

@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@400;500;700&display=swap');

/* ========================================
   BASE STYLES
   ======================================== */

:root {
  --color-primary: #2563eb;
  --color-primary-dark: #1d4ed8;
  --color-success: #059669;
  --color-warning: #d97706;
  --color-error: #dc2626;
  --color-info: #0284c7;
  
  --bg-dark: #1f2937;
  --bg-darker: #111827;
  --bg-light: #374151;
  
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  
  --border-color: #4b5563;
  --shadow-color: rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Tajawal', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ========================================
   CANVAS STYLES
   ======================================== */

#canvas-wrapper {
  position: relative;
  background-color: #e5e7eb;
  background-image: 
    linear-gradient(45deg, #d1d5db 25%, transparent 25%), 
    linear-gradient(-45deg, #d1d5db 25%, transparent 25%), 
    linear-gradient(45deg, transparent 75%, #d1d5db 75%), 
    linear-gradient(-45deg, transparent 75%, #d1d5db 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

.canvas-container {
  background: transparent !important;
}

#canvas-wrapper.drag-over {
  background-color: rgba(37, 99, 235, 0.1);
  border: 3px dashed var(--color-primary);
}

/* ========================================
   FORM ELEMENTS
   ======================================== */

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  background: var(--bg-light);
  border-radius: 4px;
  height: 6px;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--color-primary);
  cursor: pointer;
  border: 2px solid white;
  box-shadow: 0 2px 4px var(--shadow-color);
}

input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--color-primary);
  cursor: pointer;
  border: 2px solid white;
  box-shadow: 0 2px 4px var(--shadow-color);
}

input[type="range"]:focus {
  outline: none;
}

input[type="range"]:focus::-webkit-slider-thumb {
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.3);
}

/* ========================================
   SCROLLBAR STYLES
   ======================================== */

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

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

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

::-webkit-scrollbar-thumb:hover {
  background: #4b5563;
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--bg-light) var(--bg-darker);
}

/* ========================================
   ANIMATIONS
   ======================================== */

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes slideIn {
  from {
    transform: translateX(-100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes scaleIn {
  from {
    transform: scale(0.9);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.animate-pulse {
  animation: pulse 2s infinite;
}

.animate-spin {
  animation: spin 1s linear infinite;
}

.animate-fade-in {
  animation: fadeIn 0.3s ease-out;
}

.animate-scale-in {
  animation: scaleIn 0.2s ease-out;
}

/* ========================================
   UTILITY CLASSES
   ======================================== */

.dir-rtl {
  direction: rtl;
}

.dir-ltr {
  direction: ltr;
}

/* Focus styles for accessibility */
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Selection color */
::selection {
  background-color: var(--color-primary);
  color: white;
}

/* ========================================
   RESPONSIVE ADJUSTMENTS
   ======================================== */

@media (max-width: 768px) {
  .w-80 {
    width: 100%;
    max-width: 280px;
  }
  
  .w-16 {
    width: 56px;
  }
  
  .tool-btn {
    width: 40px !important;
    height: 40px !important;
  }
}

@media (max-width: 640px) {
  /* Stack layout on small screens */
  .flex.h-screen {
    flex-direction: column;
  }
  
  .w-16,
  .w-80 {
    width: 100%;
    height: auto;
    max-height: 50vh;
    overflow-y: auto;
  }
  
  .w-16 {
    flex-direction: row !important;
    padding: 8px !important;
  }
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
  .tool-btn,
  #canvas-wrapper > div:not(#c),
  .w-16,
  .w-80 {
    display: none !important;
  }
  
  #canvas-wrapper {
    width: 100% !important;
    height: auto !important;
  }
}

/* ========================================
   TOOLTIP STYLES
   ======================================== */

[title] {
  position: relative;
}

/* Custom tooltip implementation could go here */

/* ========================================
   KEYBOARD SHORTCUT DISPLAY
   ======================================== */

kbd {
  display: inline-block;
  padding: 2px 6px;
  font-family: monospace;
  font-size: 0.75rem;
  background-color: #e5e7eb;
  border-radius: 4px;
  border: 1px solid #d1d5db;
  box-shadow: 0 1px 0 #9ca3af;
}

/* ========================================
   LOADING STATES
   ======================================== */

.skeleton {
  background: linear-gradient(90deg, var(--bg-light) 25%, var(--bg-dark) 50%, var(--bg-light) 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
}

@keyframes skeleton-loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* ========================================
   ROOM TYPE COLORS (for reference)
   ======================================== */

.room-patient { --room-color: rgba(59, 130, 246, 0.4); --room-stroke: #2563eb; }
.room-clinical { --room-color: rgba(239, 68, 68, 0.4); --room-stroke: #dc2626; }
.room-admin { --room-color: rgba(16, 185, 129, 0.4); --room-stroke: #059669; }
.room-service { --room-color: rgba(107, 114, 128, 0.4); --room-stroke: #4b5563; }
.room-corridor { --room-color: rgba(251, 191, 36, 0.4); --room-stroke: #d97706; }
.room-entrance { --room-color: rgba(139, 92, 246, 0.4); --room-stroke: #7c3aed; }

/* ========================================
   SPACE MATERIALS UI STYLES
   واجهة إدارة مواد الفراغات
   ======================================== */

/* Modal container */
#space-materials-modal {
  backdrop-filter: blur(4px);
}

#space-materials-modal .bg-gray-850 {
  background-color: #1a1f2e;
}

#space-materials-modal .bg-gray-900 {
  background-color: #0f1419;
}

/* Mode buttons */
#space-materials-modal .mode-btn {
  color: #9ca3af;
  background: transparent;
  border: none;
  cursor: pointer;
}

#space-materials-modal .mode-btn:hover {
  background-color: rgba(99, 102, 241, 0.2);
  color: #a5b4fc;
}

#space-materials-modal .mode-btn.active {
  background-color: #4f46e5;
  color: white;
}

/* Space list items */
#space-materials-modal .space-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  border: 2px solid transparent;
}

#space-materials-modal .space-item:hover {
  background-color: rgba(99, 102, 241, 0.1);
}

#space-materials-modal .space-item.selected {
  background-color: rgba(99, 102, 241, 0.2);
  border-color: #6366f1;
}

#space-materials-modal .space-item .space-color {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  flex-shrink: 0;
}

#space-materials-modal .space-item .space-info {
  flex: 1;
  min-width: 0;
}

#space-materials-modal .space-item .space-name {
  font-weight: 600;
  color: white;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#space-materials-modal .space-item .space-type {
  font-size: 0.75rem;
  color: #9ca3af;
}

#space-materials-modal .space-item .space-area {
  font-size: 0.75rem;
  color: #60a5fa;
  font-family: monospace;
  flex-shrink: 0;
}

/* Category tabs */
#space-materials-modal .category-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 16px;
  color: #9ca3af;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  font-size: 0.875rem;
  background: none;
  border-left: none;
  border-right: none;
  border-top: none;
}

#space-materials-modal .category-tab:hover {
  color: #e5e7eb;
  background-color: rgba(99, 102, 241, 0.1);
}

#space-materials-modal .category-tab.active {
  color: white;
  border-bottom-color: #6366f1;
  background-color: rgba(99, 102, 241, 0.15);
}

#space-materials-modal .category-tab i {
  font-size: 1rem;
}

/* Material cards */
#space-materials-modal .material-card {
  background-color: #1f2937;
  border-radius: 8px;
  padding: 12px;
  border: 1px solid #374151;
  transition: all 0.2s;
}

#space-materials-modal .material-card:hover {
  border-color: #4b5563;
  background-color: #263240;
}

#space-materials-modal .material-card.selected {
  border-color: #22c55e;
  background-color: rgba(34, 197, 94, 0.1);
}

#space-materials-modal .material-card .material-code {
  font-size: 0.7rem;
  color: #9ca3af;
  font-family: monospace;
  background-color: rgba(0, 0, 0, 0.3);
  padding: 2px 6px;
  border-radius: 4px;
}

#space-materials-modal .material-card .material-name {
  font-weight: 600;
  color: white;
  margin-top: 4px;
}

#space-materials-modal .material-card .material-details {
  font-size: 0.75rem;
  color: #9ca3af;
  margin-top: 4px;
  display: flex;
  justify-content: space-between;
}

#space-materials-modal .material-card .material-price {
  color: #4ade80;
  font-family: monospace;
}

/* Action buttons for materials */
#space-materials-modal .material-card .material-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

#space-materials-modal .material-card .material-actions button {
  flex: 1;
  padding: 6px;
  border-radius: 4px;
  font-size: 0.75rem;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}

#space-materials-modal .material-card .btn-add {
  background-color: #3b82f6;
  color: white;
}

#space-materials-modal .material-card .btn-add:hover {
  background-color: #2563eb;
}

#space-materials-modal .material-card .btn-remove {
  background-color: #ef4444;
  color: white;
}

#space-materials-modal .material-card .btn-remove:hover {
  background-color: #dc2626;
}

/* Cost summary */
#space-materials-modal .cost-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #374151;
}

#space-materials-modal .cost-item:last-child {
  border-bottom: none;
}

#space-materials-modal .cost-item .cost-label {
  color: #9ca3af;
  font-size: 0.875rem;
}

#space-materials-modal .cost-item .cost-value {
  color: white;
  font-family: monospace;
  font-weight: 600;
}

#space-materials-modal .cost-item.total {
  padding-top: 12px;
  margin-top: 8px;
  border-top: 2px solid #4b5563;
}

#space-materials-modal .cost-item.total .cost-label {
  color: white;
  font-weight: 700;
}

#space-materials-modal .cost-item.total .cost-value {
  color: #4ade80;
  font-size: 1.25rem;
}

/* Presets Modal */
#presets-modal {
  backdrop-filter: blur(4px);
}

#presets-modal .preset-card {
  background-color: #1f2937;
  border-radius: 8px;
  padding: 12px;
  border: 1px solid #374151;
  cursor: pointer;
  transition: all 0.2s;
}

#presets-modal .preset-card:hover {
  border-color: #6366f1;
  background-color: rgba(99, 102, 241, 0.1);
}

#presets-modal .preset-card.active {
  border-color: #6366f1;
  background-color: rgba(99, 102, 241, 0.2);
}

/* Empty states */
#space-materials-modal .empty-state {
  text-align: center;
  padding: 40px 20px;
  color: #6b7280;
}

#space-materials-modal .empty-state i {
  font-size: 3rem;
  margin-bottom: 12px;
  opacity: 0.3;
}

#space-materials-modal .empty-state p {
  margin: 0;
}

/* Checkbox for multi-select */
#space-materials-modal .space-checkbox {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 2px solid #4b5563;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
}

#space-materials-modal .space-checkbox.checked {
  background-color: #6366f1;
  border-color: #6366f1;
}

#space-materials-modal .space-checkbox.checked i {
  color: white;
  font-size: 0.7rem;
}

/* Quantity input in material card */
#space-materials-modal .material-card .quantity-input {
  width: 60px;
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid #4b5563;
  background-color: #374151;
  color: white;
  font-size: 0.875rem;
  text-align: center;
}

#space-materials-modal .material-card .quantity-input:focus {
  outline: none;
  border-color: #6366f1;
}

/* Save preset modal */
#save-preset-modal {
  backdrop-filter: blur(4px);
}

#save-preset-modal .form-group {
  margin-bottom: 16px;
}

#save-preset-modal label {
  display: block;
  margin-bottom: 6px;
  color: #9ca3af;
  font-size: 0.875rem;
}

#save-preset-modal input,
#save-preset-modal textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid #4b5563;
  background-color: #1f2937;
  color: white;
  font-size: 0.875rem;
}

#save-preset-modal input:focus,
#save-preset-modal textarea:focus {
  outline: none;
  border-color: #6366f1;
}

/* Responsive adjustments for space materials UI */
@media (max-width: 1280px) {
  #space-materials-modal .w-72 {
    width: 240px;
  }
}

@media (max-width: 1024px) {
  #space-materials-modal > div > div {
    max-width: 100%;
    margin: 8px;
    max-height: calc(100vh - 16px);
  }
  
  #space-materials-modal .w-72 {
    width: 200px;
  }
}

@media (max-width: 768px) {
  #space-materials-modal > div > div {
    flex-direction: column;
  }
  
  #space-materials-modal .w-72 {
    width: 100%;
    max-height: 200px;
  }
  
  #space-materials-modal .flex-1.flex.overflow-hidden {
    flex-direction: column;
  }
  
  #space-materials-modal .w-1\/2 {
    width: 100%;
  }
}

/* ========================================
   STRUCTURAL SYSTEM UI STYLES
   واجهة نظام الهيكل الإنشائي
   ======================================== */

/* Main Modal */
#structural-modal {
  backdrop-filter: blur(4px);
}

#structural-modal .bg-gray-850 {
  background-color: #1a1f2e;
}

/* Tabs */
#structural-modal .structural-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 20px;
  color: #9ca3af;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  font-size: 0.875rem;
  font-weight: 500;
}

#structural-modal .structural-tab:hover {
  color: #e5e7eb;
  background-color: rgba(59, 130, 246, 0.1);
}

#structural-modal .structural-tab.active {
  color: #60a5fa;
  border-bottom-color: #3b82f6;
  background-color: rgba(59, 130, 246, 0.15);
}

#structural-modal .structural-tab i {
  font-size: 1rem;
}

/* Element Type Selection Buttons */
#structural-modal .slab-type-btn,
#structural-modal .beam-type-btn,
#structural-modal .column-type-btn,
#structural-modal .stair-type-btn,
#structural-modal .foundation-type-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px;
  background: transparent;
  cursor: pointer;
  transition: all 0.2s ease;
}

#structural-modal .slab-type-btn:hover,
#structural-modal .beam-type-btn:hover,
#structural-modal .column-type-btn:hover,
#structural-modal .stair-type-btn:hover,
#structural-modal .foundation-type-btn:hover {
  background-color: rgba(59, 130, 246, 0.1);
  transform: translateY(-2px);
}

#structural-modal .slab-type-btn i,
#structural-modal .beam-type-btn i,
#structural-modal .column-type-btn i,
#structural-modal .stair-type-btn i,
#structural-modal .foundation-type-btn i {
  font-size: 1.5rem;
  opacity: 0.8;
  transition: opacity 0.2s;
}

#structural-modal .slab-type-btn:hover i,
#structural-modal .beam-type-btn:hover i,
#structural-modal .column-type-btn:hover i,
#structural-modal .stair-type-btn:hover i,
#structural-modal .foundation-type-btn:hover i {
  opacity: 1;
}

/* Element List Items */
#structural-modal .element-item {
  transition: all 0.2s ease;
}

#structural-modal .element-item:hover {
  transform: translateX(-4px);
}

#structural-modal .element-item.ring-2 {
  box-shadow: 0 0 0 2px #3b82f6;
}

/* Results Section */
#structural-modal #slab-results,
#structural-modal #beam-results,
#structural-modal #column-results,
#structural-modal #stair-results,
#structural-modal #foundation-results {
  animation: slideIn 0.3s ease-out;
}

/* Progress Bars in Summary */
#structural-modal .bg-blue-500,
#structural-modal .bg-green-500,
#structural-modal .bg-purple-500,
#structural-modal .bg-orange-500,
#structural-modal .bg-pink-500 {
  transition: width 0.5s ease-out;
}

/* Settings Modal */
#structural-settings-modal {
  backdrop-filter: blur(4px);
}

#structural-settings-modal .input-dark {
  width: 100%;
  background: #374151;
  border: 1px solid #4b5563;
  border-radius: 6px;
  padding: 8px 12px;
  color: white;
  font-size: 0.875rem;
  transition: border-color 0.2s;
}

#structural-settings-modal .input-dark:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

/* Summary Cards */
#structural-modal .summary-card {
  background: linear-gradient(135deg, var(--card-from) 0%, var(--card-to) 100%);
  border-radius: 12px;
  padding: 16px;
  transition: transform 0.2s ease;
}

#structural-modal .summary-card:hover {
  transform: scale(1.02);
}

/* Gradient backgrounds for summary cards */
.from-blue-900 { --card-from: #1e3a8a; }
.to-blue-800 { --card-to: #1e40af; }
.from-green-900 { --card-from: #14532d; }
.to-green-800 { --card-to: #166534; }
.from-orange-900 { --card-from: #7c2d12; }
.to-orange-800 { --card-to: #9a3412; }

/* Footer Summary */
#structural-modal .p-3.border-t {
  background: linear-gradient(180deg, #111827 0%, #0f1419 100%);
}

/* Export Buttons */
#structural-modal #btn-export-structural-excel,
#structural-modal #btn-export-structural-json,
#structural-modal #btn-print-structural {
  transition: all 0.2s ease;
}

#structural-modal #btn-export-structural-excel:hover,
#structural-modal #btn-export-structural-json:hover,
#structural-modal #btn-print-structural:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Animations for structural elements */
@keyframes highlightElement {
  0%, 100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); }
  50% { box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.4); }
}

#structural-modal .element-item.highlight {
  animation: highlightElement 1s ease-in-out 2;
}

/* Canvas Slab Drawing Mode */
canvas.structural-drawing-mode {
  cursor: crosshair !important;
}

/* Slab outline on canvas */
.slab-outline {
  stroke: #f97316;
  stroke-width: 3;
  stroke-dasharray: 8, 4;
  fill: rgba(249, 115, 22, 0.1);
}

/* Opening (منور) outline on canvas */
.opening-outline {
  stroke: #a855f7;
  stroke-width: 2;
  stroke-dasharray: 5, 3;
  fill: rgba(168, 85, 247, 0.15);
}

/* Column markers on canvas */
.column-marker {
  fill: #3b82f6;
  stroke: #1d4ed8;
  stroke-width: 2;
}

/* Beam lines on canvas */
.beam-line {
  stroke: #22c55e;
  stroke-width: 4;
  stroke-linecap: round;
}

/* Responsive adjustments for structural modal */
@media (max-width: 1280px) {
  #structural-modal .w-72 {
    width: 240px;
  }
  
  #structural-modal .grid-cols-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1024px) {
  #structural-modal > div > div {
    max-width: 100%;
    margin: 8px;
    max-height: calc(100vh - 16px);
  }
  
  #structural-modal .structural-tab {
    padding: 10px 12px;
    font-size: 0.75rem;
  }
  
  #structural-modal .structural-tab span {
    display: none;
  }
}

@media (max-width: 768px) {
  #structural-modal > div > div {
    flex-direction: column;
  }
  
  #structural-modal .w-72 {
    width: 100%;
    max-height: 180px;
    border-left: none;
    border-bottom: 1px solid #374151;
  }
  
  #structural-modal .structural-tab {
    padding: 8px 10px;
  }
  
  #structural-modal .grid-cols-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Print styles for structural report */
@media print {
  #structural-modal {
    position: static !important;
    background: white !important;
    color: black !important;
  }
  
  #structural-modal .bg-gray-800,
  #structural-modal .bg-gray-700,
  #structural-modal .bg-gray-900 {
    background: white !important;
    color: black !important;
  }
  
  #structural-modal button {
    display: none !important;
  }
  
  #structural-modal .border-gray-700 {
    border-color: #e5e7eb !important;
  }
}
