// ============================================================================
// Enterprise Create Appointment Component Styles
// Modern, Professional, and Responsive Styling
// ============================================================================

// ============================================================================
// Component Root & Variables
// ============================================================================

:host,
app-create-appointment {
  display: block;
  width: 100%;
}

// ============================================================================
// Main Section Container
// ============================================================================

.create-section {
  width: 100%;
  padding: var(--space-xl, 2rem);
  background: transparent;
  
  @media (max-width: 768px) {
    padding: var(--space-md, 1rem);
  }
}

// ============================================================================
// Section Title
// ============================================================================

.section-title {
  font-size: var(--font-size-3xl, 1.875rem);
  font-weight: var(--font-weight-bold, 700);
  color: var(--text-primary, #111827);
  margin: 0 0 var(--space-2xl, 3rem) 0;
  line-height: var(--line-height-tight, 1.25);
  position: relative;
  padding-bottom: var(--space-md, 1rem);
  
  &::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 60px;
    height: 4px;
    background: linear-gradient(135deg, var(--color-primary, #2563eb) 0%, var(--color-accent, #8b5cf6) 100%);
    border-radius: var(--radius-full, 9999px);
  }
  
  @media (max-width: 768px) {
    font-size: var(--font-size-2xl, 1.5rem);
    margin-bottom: var(--space-xl, 2rem);
  }
}

// ============================================================================
// Form Container
// ============================================================================

.create-form-container {
  background: var(--bg-primary, #ffffff);
  border-radius: var(--radius-xl, 1rem);
  padding: var(--space-xl, 2rem);
  box-shadow: var(--shadow-lg, 0 10px 15px -3px rgba(0, 0, 0, 0.1));
  border: 1px solid var(--color-gray-200, #e5e7eb);
  transition: all var(--transition-base, 200ms cubic-bezier(0.4, 0, 0.2, 1));
  position: relative;
  overflow: hidden;
  
  &::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, var(--color-primary, #2563eb) 0%, var(--color-accent, #8b5cf6) 100%);
  }
  
  &:hover {
    box-shadow: var(--shadow-xl, 0 20px 25px -5px rgba(0, 0, 0, 0.1));
    border-color: var(--color-primary, #2563eb);
  }
  
  @media (max-width: 768px) {
    padding: var(--space-lg, 1.5rem);
    border-radius: var(--radius-lg, 0.75rem);
  }
}

// ============================================================================
// Info Message
// ============================================================================

.info-message {
  display: flex;
  align-items: flex-start;
  gap: var(--space-md, 1rem);
  padding: var(--space-md, 1rem) var(--space-lg, 1.5rem);
  background: var(--color-info-light, #dbeafe);
  border: 1px solid var(--color-info, #3b82f6);
  border-radius: var(--radius-lg, 0.75rem);
  color: var(--color-info, #3b82f6);
  font-size: var(--font-size-sm, 0.875rem);
  line-height: var(--line-height-relaxed, 1.75);
  margin-bottom: var(--space-xl, 2rem);
  position: relative;
  
  svg {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    margin-top: var(--space-xs, 0.25rem);
    opacity: 0.8;
  }
  
  div {
    flex: 1;
    
    strong {
      font-weight: var(--font-weight-semibold, 600);
      display: block;
      margin-bottom: var(--space-xs, 0.25rem);
    }
  }
  
  @media (max-width: 768px) {
    padding: var(--space-sm, 0.5rem) var(--space-md, 1rem);
    flex-direction: column;
    gap: var(--space-sm, 0.5rem);
    
    svg {
      align-self: flex-start;
    }
  }
}

// ============================================================================
// Form Elements
// ============================================================================

.create-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-xl, 2rem);
  
  @media (max-width: 768px) {
    gap: var(--space-lg, 1.5rem);
  }
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs, 0.25rem);
  
  &:last-child {
    margin-bottom: 0;
  }
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-lg, 1.5rem);
  
  @media (max-width: 1024px) {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: var(--space-md, 1rem);
  }
  
  @media (max-width: 640px) {
    grid-template-columns: 1fr;
    gap: var(--space-md, 1rem);
  }
}

.form-label {
  font-size: var(--font-size-sm, 0.875rem);
  font-weight: var(--font-weight-medium, 500);
  color: var(--text-primary, #111827);
  margin-bottom: var(--space-xs, 0.25rem);
  display: flex;
  align-items: center;
  gap: var(--space-xs, 0.25rem);
  
  &::after {
    content: '*';
    color: var(--color-danger, #ef4444);
    font-weight: var(--font-weight-bold, 700);
    margin-left: var(--space-xs, 0.25rem);
  }
  
  // Remove asterisk for non-required fields if needed
  &.optional::after {
    display: none;
  }
}

.form-input {
  width: 100%;
  padding: var(--space-sm, 0.5rem) var(--space-md, 1rem);
  border: 2px solid var(--color-gray-300, #d1d5db);
  border-radius: var(--radius-md, 0.5rem);
  background: var(--bg-primary, #ffffff);
  color: var(--text-primary, #111827);
  font-size: var(--font-size-base, 1rem);
  font-family: var(--font-family-base, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
  transition: all var(--transition-base, 200ms cubic-bezier(0.4, 0, 0.2, 1));
  appearance: none;
  
  &:hover {
    border-color: var(--color-primary, #2563eb);
  }
  
  &:focus {
    outline: none;
    border-color: var(--color-primary, #2563eb);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
  }
  
  &::placeholder {
    color: var(--color-gray-400, #9ca3af);
  }
  
  &:disabled {
    background: var(--color-gray-100, #f3f4f6);
    color: var(--text-disabled, #9ca3af);
    cursor: not-allowed;
    border-color: var(--color-gray-200, #e5e7eb);
  }
  
  // Number input styling
  &[type="number"] {
    &::-webkit-inner-spin-button,
    &::-webkit-outer-spin-button {
      opacity: 1;
      height: auto;
      cursor: pointer;
    }
  }
  
  // Date and time input styling
  &[type="date"],
  &[type="time"] {
    position: relative;
    
    &::-webkit-calendar-picker-indicator {
      cursor: pointer;
      opacity: 0.6;
      transition: opacity var(--transition-base, 200ms cubic-bezier(0.4, 0, 0.2, 1));
      
      &:hover {
        opacity: 1;
      }
    }
  }
}

// Select dropdown specific styling
select.form-input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9L12 15L18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-sm, 0.5rem) center;
  background-size: 20px;
  padding-right: var(--space-2xl, 3rem);
  cursor: pointer;
  
  option {
    padding: var(--space-sm, 0.5rem);
    background: var(--bg-primary, #ffffff);
    color: var(--text-primary, #111827);
  }
}

// Manual input margin
.form-input-margin {
  margin-top: var(--space-md, 1rem);
}

// ============================================================================
// Form Error Message
// ============================================================================

.form-error-message {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md, 1rem);
  padding: var(--space-md, 1rem) var(--space-lg, 1.5rem);
  background: var(--color-danger-light, #fee2e2);
  border: 1px solid var(--color-danger, #ef4444);
  border-radius: var(--radius-md, 0.5rem);
  color: var(--color-danger, #ef4444);
  font-size: var(--font-size-sm, 0.875rem);
  margin-top: calc(var(--space-lg, 1.5rem) * -1);
  margin-bottom: var(--space-lg, 1.5rem);
  animation: slideDown var(--transition-base, 200ms cubic-bezier(0.4, 0, 0.2, 1));
  
  strong {
    font-weight: var(--font-weight-semibold, 600);
  }
  
  button {
    background: transparent;
    border: none;
    color: var(--color-danger, #ef4444);
    font-size: var(--font-size-xl, 1.25rem);
    font-weight: var(--font-weight-bold, 700);
    cursor: pointer;
    padding: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm, 0.375rem);
    transition: all var(--transition-base, 200ms cubic-bezier(0.4, 0, 0.2, 1));
    flex-shrink: 0;
    line-height: 1;
    
    &:hover {
      background: var(--color-danger, #ef4444);
      color: var(--text-inverse, #ffffff);
      transform: scale(1.1);
    }
    
    &:active {
      transform: scale(0.95);
    }
  }
  
  @media (max-width: 640px) {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-sm, 0.5rem);
  }
}

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

// ============================================================================
// Submit Button
// ============================================================================

.submit-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm, 0.5rem);
  padding: var(--space-md, 1rem) var(--space-2xl, 3rem);
  border: none;
  border-radius: var(--radius-md, 0.5rem);
  background: linear-gradient(135deg, var(--color-primary, #2563eb) 0%, var(--color-accent, #8b5cf6) 100%);
  color: var(--text-inverse, #ffffff);
  font-size: var(--font-size-lg, 1.125rem);
  font-weight: var(--font-weight-semibold, 600);
  cursor: pointer;
  transition: all var(--transition-base, 200ms cubic-bezier(0.4, 0, 0.2, 1));
  box-shadow: var(--shadow-md, 0 4px 6px -1px rgba(0, 0, 0, 0.1));
  position: relative;
  overflow: hidden;
  align-self: flex-start;
  min-width: 200px;
  
  &::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
  }
  
  &::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
  }
  
  &:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--color-accent, #8b5cf6) 0%, var(--color-primary, #2563eb) 100%);
    box-shadow: var(--shadow-lg, 0 10px 15px -3px rgba(0, 0, 0, 0.1));
    transform: translateY(-2px);
    
    &::before {
      width: 300px;
      height: 300px;
    }
    
    &::after {
      left: 100%;
    }
  }
  
  &:active:not(:disabled) {
    transform: translateY(0);
  }
  
  &:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
  }
  
  // Loading state (if needed)
  &.loading {
    position: relative;
    color: transparent;
    
    &::after {
      content: '';
      position: absolute;
      top: 50%;
      left: 50%;
      width: 20px;
      height: 20px;
      border: 3px solid rgba(255, 255, 255, 0.3);
      border-top-color: var(--text-inverse, #ffffff);
      border-radius: 50%;
      transform: translate(-50%, -50%);
      animation: spin 0.8s linear infinite;
    }
  }
  
  @media (max-width: 640px) {
    width: 100%;
    align-self: stretch;
    min-width: 0;
    padding: var(--space-md, 1rem) var(--space-xl, 2rem);
  }
}

@keyframes spin {
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

// ============================================================================
// Form Validation States
// ============================================================================

.form-group {
  &.has-error {
    .form-input {
      border-color: var(--color-danger, #ef4444);
      
      &:focus {
        box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
      }
    }
    
    .form-label {
      color: var(--color-danger, #ef4444);
    }
  }
  
  &.has-success {
    .form-input {
      border-color: var(--color-success, #10b981);
      
      &:focus {
        box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
      }
    }
  }
}

// ============================================================================
// Patient Selection Enhancement
// ============================================================================

.form-group {
  // Special styling for patient selection with manual input
  &:has(input.form-input-margin) {
    position: relative;
    
    .form-input-margin {
      border-top: none;
      border-top-left-radius: 0;
      border-top-right-radius: 0;
      border-color: var(--color-gray-300, #d1d5db);
      background: var(--bg-secondary, #f9fafb);
      
      &::before {
        content: 'OR';
        position: absolute;
        top: -12px;
        left: 50%;
        transform: translateX(-50%);
        background: var(--bg-primary, #ffffff);
        padding: 0 var(--space-sm, 0.5rem);
        color: var(--text-secondary, #4b5563);
        font-size: var(--font-size-xs, 0.75rem);
        font-weight: var(--font-weight-medium, 500);
      }
      
      &:focus {
        background: var(--bg-primary, #ffffff);
        border-color: var(--color-primary, #2563eb);
      }
    }
  }
}

// ============================================================================
// Responsive Enhancements
// ============================================================================

@media (max-width: 768px) {
  .create-form-container {
    border-radius: var(--radius-lg, 0.75rem);
  }
  
  .form-row {
    grid-template-columns: 1fr;
  }
  
  .submit-button {
    font-size: var(--font-size-base, 1rem);
  }
}

@media (max-width: 480px) {
  .create-section {
    padding: var(--space-sm, 0.5rem);
  }
  
  .create-form-container {
    padding: var(--space-md, 1rem);
  }
  
  .form-input {
    font-size: var(--font-size-sm, 0.875rem);
    padding: var(--space-sm, 0.5rem) var(--space-md, 1rem);
  }
}

// ============================================================================
// Focus Visible for Accessibility
// ============================================================================

.form-input:focus-visible,
.submit-button:focus-visible {
  outline: 2px solid var(--color-primary, #2563eb);
  outline-offset: 2px;
}

// ============================================================================
// Print Styles (Optional)
// ============================================================================

@media print {
  .create-section {
    padding: 0;
  }
  
  .create-form-container {
    box-shadow: none;
    border: 1px solid var(--color-gray-300, #d1d5db);
    padding: var(--space-md, 1rem);
  }
  
  .submit-button,
  .info-message {
    display: none;
  }
  
  .form-input {
    border: 1px solid var(--color-gray-400, #9ca3af);
    background: transparent;
  }
}

// ============================================================================
// Loading State (if needed)
// ============================================================================

.create-form-container {
  &.loading {
    position: relative;
    
    &::after {
      content: '';
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background: rgba(255, 255, 255, 0.8);
      display: flex;
      align-items: center;
      justify-content: center;
      border-radius: var(--radius-xl, 1rem);
      z-index: 10;
    }
  }
}

// ============================================================================
// Notification Popup
// ============================================================================

.notification-popup {
  position: fixed;
  top: var(--space-xl, 2rem);
  right: var(--space-xl, 2rem);
  z-index: var(--z-modal, 1050);
  min-width: 350px;
  max-width: 500px;
  background: var(--bg-primary, #ffffff);
  border-radius: var(--radius-lg, 0.75rem);
  box-shadow: var(--shadow-2xl, 0 25px 50px -12px rgba(0, 0, 0, 0.25));
  border: 1px solid var(--color-gray-200, #e5e7eb);
  animation: slideInRight var(--transition-slow, 300ms cubic-bezier(0.4, 0, 0.2, 1));
  overflow: hidden;
  
  @media (max-width: 768px) {
    top: var(--space-md, 1rem);
    right: var(--space-md, 1rem);
    left: var(--space-md, 1rem);
    min-width: auto;
    max-width: none;
  }
}

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

.popup-content {
  display: flex;
  align-items: flex-start;
  gap: var(--space-md, 1rem);
  padding: var(--space-lg, 1.5rem);
  position: relative;
}

.popup-icon {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full, 9999px);
  display: flex;
  align-items: center;
  justify-content: center;
  
  svg {
    width: 24px;
    height: 24px;
  }
}

.popup-success .popup-icon {
  background: var(--color-success-light, #d1fae5);
  color: var(--color-success, #10b981);
}

.popup-error .popup-icon {
  background: var(--color-danger-light, #fee2e2);
  color: var(--color-danger, #ef4444);
}

.popup-message {
  flex: 1;
  min-width: 0;
}

.popup-title {
  font-size: var(--font-size-lg, 1.125rem);
  font-weight: var(--font-weight-semibold, 600);
  color: var(--text-primary, #111827);
  margin: 0 0 var(--space-xs, 0.25rem) 0;
  line-height: var(--line-height-tight, 1.25);
}

.popup-text {
  font-size: var(--font-size-sm, 0.875rem);
  color: var(--text-secondary, #4b5563);
  margin: 0;
  line-height: var(--line-height-normal, 1.5);
}

.popup-close {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-tertiary, #6b7280);
  cursor: pointer;
  border-radius: var(--radius-sm, 0.375rem);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-base, 200ms cubic-bezier(0.4, 0, 0.2, 1));
  
  svg {
    width: 18px;
    height: 18px;
  }
  
  &:hover {
    background: var(--color-gray-100, #f3f4f6);
    color: var(--text-primary, #111827);
  }
  
  &:active {
    transform: scale(0.95);
  }
}

.popup-refresh-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs, 0.25rem);
  margin-top: var(--space-md, 1rem);
  padding: var(--space-xs, 0.25rem) var(--space-md, 1rem);
  border: 2px solid var(--color-primary, #2563eb);
  border-radius: var(--radius-md, 0.5rem);
  background: var(--bg-primary, #ffffff);
  color: var(--color-primary, #2563eb);
  font-size: var(--font-size-sm, 0.875rem);
  font-weight: var(--font-weight-medium, 500);
  cursor: pointer;
  transition: all var(--transition-base, 200ms cubic-bezier(0.4, 0, 0.2, 1));
  
  svg {
    width: 16px;
    height: 16px;
  }
  
  &:hover {
    background: var(--color-primary, #2563eb);
    color: var(--text-inverse, #ffffff);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md, 0 4px 6px -1px rgba(0, 0, 0, 0.1));
  }
  
  &:active {
    transform: translateY(0);
  }
}

.popup-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--color-success, #10b981) 0%, var(--color-secondary-dark, #059669) 100%);
  animation: progressBar 3s linear forwards;
}

@keyframes progressBar {
  from {
    width: 100%;
  }
  to {
    width: 0;
  }
}

// Popup variants
.popup-success {
  border-left: 4px solid var(--color-success, #10b981);
}

.popup-error {
  border-left: 4px solid var(--color-danger, #ef4444);
}

// Responsive adjustments
@media (max-width: 640px) {
  .notification-popup {
    border-radius: var(--radius-md, 0.5rem);
  }
  
  .popup-content {
    padding: var(--space-md, 1rem);
    gap: var(--space-sm, 0.5rem);
  }
  
  .popup-icon {
    width: 40px;
    height: 40px;
    
    svg {
      width: 20px;
      height: 20px;
    }
  }
  
  .popup-title {
    font-size: var(--font-size-base, 1rem);
  }
  
  .popup-text {
    font-size: var(--font-size-xs, 0.75rem);
  }
  
  .popup-close {
    width: 28px;
    height: 28px;
    
    svg {
      width: 16px;
      height: 16px;
    }
  }
}

