/**
 * Calculator Projects V2 - Modern UI för projekthantering
 */

/* ==================== MODAL BASE ==================== */

.calculator-projects-modal,
.calculator-save-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.calculator-projects-modal.open,
.calculator-save-modal.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(4px);
}

.modal-container {
  position: relative;
  background: white;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  max-width: 600px;
  width: 90%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  transform: translateY(20px);
  transition: transform 0.3s ease;
}

.calculator-projects-modal.open .modal-container,
.calculator-save-modal.open .modal-container {
  transform: translateY(0);
}

/* ==================== MODAL HEADER ==================== */

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem 2rem;
  border-bottom: 1px solid #e2e8f0;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  color: #1e293b;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.modal-header h2 i {
  color: #3b82f6;
}

.modal-close {
  background: #f1f5f9;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  color: #64748b;
}

.modal-close:hover {
  background: #e2e8f0;
  color: #1e293b;
}

/* ==================== MODAL BODY ==================== */

.modal-body {
  padding: 2rem;
  overflow-y: auto;
  flex: 1;
}

/* ==================== EMPTY STATE ==================== */

.empty-state {
  text-align: center;
  padding: 3rem 2rem;
  color: #64748b;
}

.empty-state h3 {
  margin: 0 0 0.5rem 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: #475569;
}

.empty-state p {
  margin: 0;
  font-size: 0.95rem;
}

/* ==================== PROJECTS LIST ==================== */

.projects-list {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.project-group {
  background: #f8fafc;
  border-radius: 12px;
  overflow: hidden;
}

.project-group-header {
  padding: 1rem 1.25rem;
  background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
  border-bottom: 1px solid #e2e8f0;
}

.project-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 600;
  color: #1e293b;
}

.project-info i {
  color: #3b82f6;
  font-size: 1.1rem;
}

.project-name {
  flex: 1;
  font-size: 1rem;
}

.calc-count {
  background: #3b82f6;
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 600;
}

.btn-export {
  background: linear-gradient(135deg, #059669 0%, #10b981 100%);
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(5, 150, 105, 0.2);
}

.btn-export:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.3);
  background: linear-gradient(135deg, #047857 0%, #059669 100%);
}

/* ==================== CALCULATIONS LIST ==================== */

.calculations-list {
  display: flex;
  flex-direction: column;
}

.calculation-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: white;
  border-bottom: 1px solid #e2e8f0;
  transition: background 0.2s ease;
  cursor: pointer;
}

.calculation-item:last-child {
  border-bottom: none;
}

.calculation-item:hover {
  background: #f8fafc;
}

.calc-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.1rem;
  flex-shrink: 0;
}

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

.calc-name {
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 0.25rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calc-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: #64748b;
}

.calc-type {
  background: #eff6ff;
  color: #2563eb;
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
  font-weight: 500;
}

.calc-actions {
  display: flex;
  gap: 0.5rem;
}

.btn-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  color: #64748b;
}

.btn-icon:hover {
  background: #3b82f6;
  border-color: #3b82f6;
  color: white;
  transform: translateY(-2px);
}

.btn-icon.btn-danger:hover {
  background: #ef4444;
  border-color: #ef4444;
}

/* ==================== SAVE MODAL ==================== */

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}

.form-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  font-size: 1rem;
  transition: all 0.2s ease;
  font-family: inherit;
}

.form-input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.modal-actions {
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
  margin-top: 2rem;
}

.btn-primary,
.btn-secondary {
  padding: 0.75rem 1.5rem;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border: none;
}

.btn-primary {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.btn-secondary {
  background: white;
  color: #64748b;
  border: 2px solid #e2e8f0;
}

.btn-secondary:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

/* ==================== TOAST NOTIFICATIONS ==================== */

.calculator-toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #1e293b;
  color: white;
  padding: 1rem 1.5rem;
  border-radius: 12px;
  font-weight: 500;
  font-size: 0.95rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  z-index: 10001;
  opacity: 0;
  transition: all 0.3s ease;
  max-width: 90%;
}

.calculator-toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.calculator-toast-success {
  background: linear-gradient(135deg, #059669 0%, #10b981 100%);
}

.calculator-toast-error {
  background: linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
}

.calculator-toast-info {
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
}

/* ==================== MOBILE OPTIMIZATIONS ==================== */

@media (max-width: 768px) {
  .calculator-projects-modal .modal-container,
  .calculator-save-modal .modal-container {
    position: fixed;
    bottom: 0;
    top: auto;
    max-width: 100%;
    width: 100%;
    max-height: 90vh;
    border-radius: 24px 24px 0 0;
    transform: translateY(100%);
  }

  .calculator-projects-modal.open .modal-container,
  .calculator-save-modal.open .modal-container {
    transform: translateY(0);
  }

  .modal-header {
    padding: 1rem 1.5rem;
    position: relative;
  }

  .modal-header::before {
    content: '';
    position: absolute;
    top: 0.75rem;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 4px;
    background: #cbd5e1;
    border-radius: 2px;
  }

  .modal-header h2 {
    font-size: 1.25rem;
    margin-top: 1rem;
  }

  .modal-body {
    padding: 1.5rem;
  }

  .project-group-header {
    padding: 0.875rem 1rem;
  }

  .calculation-item {
    padding: 1rem;
  }

  .calc-name {
    font-size: 0.95rem;
  }

  .calc-meta {
    font-size: 0.8rem;
  }

  .btn-icon {
    width: 32px;
    height: 32px;
  }

  .calculator-toast {
    bottom: 5.5rem; /* Ovanför mobile bottom nav */
  }
}

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

@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

.calculation-item {
  animation: slideInUp 0.3s ease forwards;
}

.calculation-item:nth-child(1) { animation-delay: 0.05s; }
.calculation-item:nth-child(2) { animation-delay: 0.1s; }
.calculation-item:nth-child(3) { animation-delay: 0.15s; }
.calculation-item:nth-child(4) { animation-delay: 0.2s; }
.calculation-item:nth-child(5) { animation-delay: 0.25s; }

/* ==================== DARK MODE SUPPORT (future) ==================== */

@media (prefers-color-scheme: dark) {
  .modal-container {
    background: #1e293b;
  }

  .modal-header {
    border-bottom-color: #334155;
  }

  .modal-header h2 {
    color: #f1f5f9;
  }

  .modal-close {
    background: #334155;
    color: #94a3b8;
  }

  .modal-close:hover {
    background: #475569;
    color: #f1f5f9;
  }

  .project-group {
    background: #0f172a;
  }

  .project-group-header {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    border-bottom-color: #334155;
  }

  .project-info {
    color: #f1f5f9;
  }

  .calculation-item {
    background: #1e293b;
    border-bottom-color: #334155;
  }

  .calculation-item:hover {
    background: #334155;
  }

  .calc-name {
    color: #f1f5f9;
  }

  .calc-meta {
    color: #94a3b8;
  }

  .calc-type {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
  }

  .btn-icon {
    background: #334155;
    border-color: #475569;
    color: #94a3b8;
  }

  .form-input {
    background: #0f172a;
    border-color: #334155;
    color: #f1f5f9;
  }

  .form-input:focus {
    border-color: #3b82f6;
    background: #1e293b;
  }

  .form-group label {
    color: #f1f5f9;
  }

  .btn-secondary {
    background: #334155;
    border-color: #475569;
    color: #f1f5f9;
  }

  .btn-secondary:hover {
    background: #475569;
  }

  .empty-state {
    color: #94a3b8;
  }

  .empty-state h3 {
    color: #cbd5e1;
  }
}
