/* ==========================================================================
   modals.css — Centered modal dialogs with scale + fade entrance
   ========================================================================== */

/* ---------------------------------------------------------------------------
   Overlay Backdrop
   --------------------------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal-backdrop);

  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);

  display: flex;
  align-items: center;
  justify-content: center;

  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-normal),
              visibility var(--transition-normal);
}

.modal-overlay.open,
.modal-overlay.show {
  opacity: 1;
  visibility: visible;
}

/* ---------------------------------------------------------------------------
   Modal Container
   --------------------------------------------------------------------------- */
.modal {
  position: relative;
  z-index: var(--z-modal);
  width: 90vw;
  min-width: 320px;
  max-width: 800px;
  max-height: 80vh;

  display: flex;
  flex-direction: column;

  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--elevation-shadow), 0 0 60px rgba(0, 0, 0, 0.3);

  /* Entrance animation: scale up + fade */
  opacity: 0;
  transform: scale(0.92);
  transition: opacity var(--transition-normal),
              transform var(--transition-normal);
}

.modal-overlay.open .modal,
.modal.open {
  opacity: 1;
  transform: scale(1);
}

/* Smaller modal variant */
.modal.modal-sm {
  max-width: 400px;
}

/* Large modal variant */
.modal.modal-lg {
  max-width: 800px;
}

/* ---------------------------------------------------------------------------
   Modal Header
   --------------------------------------------------------------------------- */
.modal-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: var(--glass-border);
  flex-shrink: 0;
}

.modal-header-icon {
  font-size: 22px;
  line-height: 1;
}

.modal-header-title {
  flex: 1;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: var(--glass-border);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 16px;
  cursor: pointer;
  transition: background var(--transition-fast),
              color var(--transition-fast);
}

.modal-close svg {
  width: 16px;
  height: 16px;
}

.modal-close:hover {
  background: rgba(255, 87, 87, 0.15);
  color: var(--color-danger);
}

/* ---------------------------------------------------------------------------
   Modal Body (scrollable)
   --------------------------------------------------------------------------- */
.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.6;
}

/* ---------------------------------------------------------------------------
   Modal Footer (action buttons)
   --------------------------------------------------------------------------- */
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 20px;
  border-top: var(--glass-border);
  flex-shrink: 0;
}

.modal-footer-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 20px;
  border-radius: var(--radius-md);
  border: var(--glass-border);
  background: var(--surface);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition-fast),
              box-shadow var(--transition-fast);
}

.modal-footer-btn:hover {
  background: var(--surface-hover);
}

/* Primary button (rightmost, call to action) */
.modal-footer-btn.primary {
  background: rgba(0, 212, 170, 0.18);
  border-color: rgba(0, 212, 170, 0.3);
  color: var(--color-primary);
}

.modal-footer-btn.primary:hover {
  background: rgba(0, 212, 170, 0.3);
  box-shadow: var(--glow-primary);
}

/* Danger button */
.modal-footer-btn.danger {
  background: rgba(255, 87, 87, 0.12);
  border-color: rgba(255, 87, 87, 0.25);
  color: var(--color-danger);
}

.modal-footer-btn.danger:hover {
  background: rgba(255, 87, 87, 0.22);
  box-shadow: 0 0 16px rgba(255, 87, 87, 0.12);
}

/* ---------------------------------------------------------------------------
   Morning Briefing — Objectives / Streaks / Contracts
   --------------------------------------------------------------------------- */
.objective-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; position: relative; }
.objective-row.completed { opacity: 0.6; }
.objective-progress { position: absolute; bottom: 0; left: 0; height: 2px; background: #4fc3f7; transition: width 0.3s; }
.objective-reward { margin-left: auto; color: #81c784; font-size: 0.85rem; }
.streak-badge { color: #ff9800; font-weight: 600; margin-bottom: 8px; }
.contract-summary { padding: 4px 0; font-size: 0.9rem; }
.briefing-section { margin-bottom: 16px; }
.briefing-section h3 { color: #4fc3f7; margin-bottom: 8px; font-size: 1rem; }

/* ---------------------------------------------------------------------------
   Responsive
   --------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .modal {
    width: 95vw;
    max-height: 90vh;
    border-radius: var(--radius-md);
  }

  .modal-header {
    padding: 12px 16px;
  }

  .modal-body {
    padding: 16px;
  }

  .modal-footer {
    padding: 10px 16px;
    flex-wrap: wrap;
  }
}

/* ---------------------------------------------------------------------------
   Phone breakpoint
   --------------------------------------------------------------------------- */
@media (max-width: 767px) {
    .modal {
        width: 100% !important;
        max-width: 100% !important;
        height: 100% !important;
        max-height: 100% !important;
        border-radius: 0;
        margin: 0;
        min-width: unset;
    }

    .modal-header {
        padding: 12px 16px;
        padding-top: calc(12px + var(--safe-top));
    }

    .modal-close {
        width: 36px;
        height: 36px;
        min-width: 36px;
    }
    .modal-close svg {
        width: 18px;
        height: 18px;
    }

    .modal-body {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 16px;
    }

    .modal-footer {
        padding: 12px 16px;
        padding-bottom: calc(12px + var(--safe-bottom));
        gap: 8px;
    }

    .modal-footer-btn {
        min-height: 44px;
        padding: 10px 16px;
        font-size: 14px;
        flex: 1;
        justify-content: center;
    }
}
