/**
 * Fabric Vector Designer - Professional UI Extensions
 * Advanced styling for modals, animations, and interactive elements
 * Version: 2.0.0
 */

/* Advanced Animations */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@keyframes slideIn {
  from { transform: translateY(-10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes slideOut {
  from { transform: translateY(0); opacity: 1; }
  to { transform: translateY(-10px); opacity: 0; }
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-2px); }
  75% { transform: translateX(2px); }
}

/* Modal System */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: fadeIn 0.2s ease;
}

.modal {
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  min-width: 400px;
  max-width: 90vw;
  max-height: 90vh;
  overflow: hidden;
  animation: slideIn 0.3s ease;
}

.modal-header {
  background: linear-gradient(180deg, #f8f8f8 0%, #f0f0f0 100%);
  border-bottom: 1px solid #d0d0d0;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: #333;
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 18px;
  color: #666;
  cursor: pointer;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 2px;
  transition: all 0.15s ease;
}

.modal-close:hover {
  background: rgba(255, 0, 0, 0.1);
  color: #d63031;
}

.modal-content {
  padding: 16px;
  max-height: 60vh;
  overflow-y: auto;
}

.modal-footer {
  background: #f8f8f8;
  border-top: 1px solid #e0e0e0;
  padding: 12px 16px;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* Buttons */
.btn {
  padding: 8px 16px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  background: #fff;
  color: #333;
}

.btn:hover {
  background: #f8f8f8;
  border-color: #999;
  text-decoration: none;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: #007acc;
  color: #fff;
  border-color: #006bb3;
}

.btn-primary:hover {
  background: #006bb3;
  color: #fff;
}

.btn-secondary {
  background: #6c757d;
  color: #fff;
  border-color: #545b62;
}

.btn-secondary:hover {
  background: #545b62;
  color: #fff;
}

.btn-success {
  background: #28a745;
  color: #fff;
  border-color: #1e7e34;
}

.btn-success:hover {
  background: #1e7e34;
  color: #fff;
}

.btn-danger {
  background: #dc3545;
  color: #fff;
  border-color: #bd2130;
}

.btn-danger:hover {
  background: #bd2130;
  color: #fff;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
}

/* Form Controls */
.option-group {
  margin-bottom: 16px;
}

.option-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #333;
  margin-bottom: 6px;
}

.radio-group,
.scale-options {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.radio-group label,
.scale-options label {
  font-weight: normal;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  margin-bottom: 0;
}

.radio-group input[type="radio"],
.scale-options input[type="radio"] {
  margin: 0;
}

input[type="text"],
input[type="number"],
input[type="range"],
select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #ccc;
  border-radius: 3px;
  font-size: 13px;
  transition: all 0.15s ease;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
  outline: none;
  border-color: #007acc;
  box-shadow: 0 0 0 2px rgba(0, 122, 204, 0.2);
}

input[type="range"] {
  padding: 0;
  height: 6px;
  background: #ddd;
  border: none;
  border-radius: 3px;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 16px;
  height: 16px;
  background: #007acc;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.15s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
  background: #006bb3;
  transform: scale(1.1);
}

input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: #007acc;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.15s ease;
}

input[type="range"]::-moz-range-thumb:hover {
  background: #006bb3;
  transform: scale(1.1);
}

.quality-value {
  font-size: 12px;
  color: #666;
  margin-left: 8px;
}

/* Context Menus */
.context-menu {
  position: absolute;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  padding: 4px 0;
  min-width: 160px;
  z-index: 1000;
  animation: fadeIn 0.15s ease;
}

.context-item {
  padding: 8px 16px;
  font-size: 13px;
  cursor: pointer;
  transition: background-color 0.15s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.context-item:hover {
  background: #f0f7ff;
}

.context-item:active {
  background: #e8f4fd;
}

.context-item.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.context-separator {
  height: 1px;
  background: #e0e0e0;
  margin: 4px 0;
}

/* Tooltips */
.tooltip {
  position: absolute;
  background: rgba(0, 0, 0, 0.9);
  color: #fff;
  padding: 6px 8px;
  font-size: 11px;
  border-radius: 3px;
  z-index: 10000;
  pointer-events: none;
  animation: fadeIn 0.2s ease;
  max-width: 200px;
  word-wrap: break-word;
}

.tooltip-content {
  position: relative;
}

.tooltip-arrow {
  position: absolute;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 4px solid rgba(0, 0, 0, 0.9);
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
}

.tooltip.top .tooltip-arrow {
  border-top: none;
  border-bottom: 4px solid rgba(0, 0, 0, 0.9);
  top: -4px;
}

.tooltip.left .tooltip-arrow {
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-right: 4px solid rgba(0, 0, 0, 0.9);
  border-left: none;
  top: 50%;
  left: 100%;
  transform: translateY(-50%);
}

.tooltip.right .tooltip-arrow {
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 4px solid rgba(0, 0, 0, 0.9);
  border-right: none;
  top: 50%;
  left: -4px;
  transform: translateY(-50%);
}

/* Drag and Drop */
.drag-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 122, 204, 0.1);
  border: 2px dashed #007acc;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: #007acc;
  font-weight: 600;
  z-index: 1000;
  animation: pulse 2s infinite;
}

.drag-preview {
  position: absolute;
  pointer-events: none;
  z-index: 10000;
  opacity: 0.8;
  transform: rotate(5deg);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Loading States */
.loading {
  position: relative;
  pointer-events: none;
  opacity: 0.6;
}

.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid #f0f0f0;
  border-left: 2px solid #007acc;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* Selection Highlights */
.selection-box {
  position: absolute;
  border: 1px solid #007acc;
  background: rgba(0, 122, 204, 0.1);
  pointer-events: none;
  z-index: 100;
}

.selection-handle {
  position: absolute;
  width: 8px;
  height: 8px;
  background: #007acc;
  border: 1px solid #fff;
  cursor: pointer;
  z-index: 101;
}

.selection-handle.nw { cursor: nw-resize; }
.selection-handle.n { cursor: n-resize; }
.selection-handle.ne { cursor: ne-resize; }
.selection-handle.e { cursor: e-resize; }
.selection-handle.se { cursor: se-resize; }
.selection-handle.s { cursor: s-resize; }
.selection-handle.sw { cursor: sw-resize; }
.selection-handle.w { cursor: w-resize; }

/* Progress Indicators */
.progress-bar {
  width: 100%;
  height: 4px;
  background: #e0e0e0;
  border-radius: 2px;
  overflow: hidden;
  margin: 8px 0;
}

.progress-fill {
  height: 100%;
  background: #007acc;
  border-radius: 2px;
  transition: width 0.3s ease;
}

.progress-indeterminate {
  background: linear-gradient(90deg, transparent, #007acc, transparent);
  background-size: 200% 100%;
  animation: progressIndeterminate 1.5s infinite;
}

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

/* Notification System */
.notification {
  position: fixed;
  top: 20px;
  right: 20px;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  padding: 12px 16px;
  min-width: 300px;
  max-width: 400px;
  z-index: 10000;
  animation: slideIn 0.3s ease;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.notification.success {
  border-left: 4px solid #28a745;
}

.notification.warning {
  border-left: 4px solid #ffc107;
}

.notification.error {
  border-left: 4px solid #dc3545;
}

.notification.info {
  border-left: 4px solid #007acc;
}

.notification-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  margin-top: 2px;
}

.notification-content {
  flex: 1;
}

.notification-title {
  font-weight: 600;
  margin-bottom: 4px;
  color: #333;
}

.notification-message {
  font-size: 13px;
  color: #666;
  line-height: 1.4;
}

.notification-close {
  background: transparent;
  border: none;
  color: #999;
  cursor: pointer;
  font-size: 16px;
  padding: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 2px;
  transition: all 0.15s ease;
}

.notification-close:hover {
  background: rgba(0, 0, 0, 0.1);
  color: #666;
}

/* Color Picker Enhancements */
.sp-container {
  border-radius: 4px !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
}

.sp-picker-container {
  border-radius: 3px !important;
}

.sp-input {
  font-size: 12px !important;
  border-radius: 3px !important;
  padding: 4px 6px !important;
}

.sp-button-container {
  text-align: right !important;
}

.sp-cancel,
.sp-choose {
  padding: 6px 12px !important;
  border-radius: 3px !important;
  font-size: 12px !important;
  border: 1px solid #ccc !important;
  margin-left: 4px !important;
}

.sp-choose {
  background: #007acc !important;
  border-color: #006bb3 !important;
}

/* High DPI Support */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .tool-btn svg,
  .panel-btn svg,
  .color-btn svg {
    transform: scale(0.9);
  }
}

/* Dark Theme Support */
.fabric-theme-dark {
  --bg-primary: #2d2d2d;
  --bg-secondary: #3c3c3c;
  --bg-tertiary: #4a4a4a;
  --text-primary: #e0e0e0;
  --text-secondary: #b0b0b0;
  --border-primary: #555;
  --border-secondary: #666;
  --accent-primary: #007acc;
  --accent-secondary: #005fa3;
}

.fabric-theme-dark .fabric-interface {
  background: var(--bg-primary);
  color: var(--text-primary);
}

.fabric-theme-dark .fabric-menubar,
.fabric-theme-dark .fabric-toolbar,
.fabric-theme-dark .panel-header {
  background: var(--bg-secondary);
  border-color: var(--border-primary);
}

.fabric-theme-dark .left-panels,
.fabric-theme-dark .right-panels {
  background: var(--bg-secondary);
  border-color: var(--border-primary);
}

.fabric-theme-dark .panel {
  border-color: var(--border-secondary);
}

.fabric-theme-dark .tool-btn,
.fabric-theme-dark .panel-btn,
.fabric-theme-dark .color-btn {
  border-color: var(--border-primary);
  color: var(--text-primary);
}

.fabric-theme-dark .tool-btn:hover,
.fabric-theme-dark .panel-btn:hover,
.fabric-theme-dark .color-btn:hover {
  background: var(--bg-tertiary);
}

/* Animation Performance Optimizations */
.fabric-designer-container * {
  will-change: auto;
}

.fabric-designer-container .tool-btn,
.fabric-designer-container .panel-btn,
.fabric-designer-container .menu-item {
  will-change: background-color, border-color;
}

.modal,
.context-menu,
.tooltip {
  will-change: transform, opacity;
}

/* Print Styles */
@media print {
  .fabric-designer-container {
    background: white !important;
    border: none !important;
  }
  
  .fabric-menubar,
  .fabric-toolbar,
  .left-panels,
  .right-panels,
  .fabric-statusbar {
    display: none !important;
  }
  
  .canvas-area {
    position: static !important;
  }
}