/*
 * WhapCab Responsive Component Styles
 * Using Tailwind CSS with BEM components and responsive utilities
 * Works for desktop browsers, mobile browsers, and Turbo Native app
 *
 * Design Philosophy:
 * - Size-based responsive design (sm:, md:, lg:) not platform-based
 * - Semantic BEM class names (no "mobile" prefix)
 * - Responsive utilities applied via @apply directive
 * - Only use Tailwind classes directly in HTML for one-off utilities
 */

/* ============================================
   NOTE: Base layout styles now in layouts/application.html.erb
   Flash messages now use inline Tailwind in layout
   ============================================ */

/* ============================================
   Mobile Main Container
   ============================================ */

.mobile-main {
  @apply px-4 py-6;
  @apply min-h-screen;
}

.mobile-body {
  @apply bg-white;
}

/* ============================================
   Driver Status Page
   ============================================ */

.driver-status {
  @apply space-y-4;
}

.driver-status__header {
  @apply bg-white rounded-xl shadow-sm p-4;
  @apply flex flex-col;
}

.driver-status__title-section {
  @apply flex-1;
}

.driver-status__title {
  @apply text-xl font-bold text-gray-900 mb-2;
}

/* Status pills with colored backgrounds */
.driver-status__current-status {
  @apply inline-flex items-center gap-1;
  @apply px-3 py-1.5 rounded-full text-sm font-semibold;
}

.driver-status__current-status--available {
  @apply bg-green-100 text-green-800;
}

.driver-status__current-status--offline {
  @apply bg-gray-200 text-gray-700;
}

.driver-status__current-status--on_break {
  @apply bg-yellow-100 text-yellow-800;
}

.driver-status__current-status--busy {
  @apply bg-blue-100 text-blue-800;
}

.driver-status__current-status--accidented {
  @apply bg-red-100 text-red-800;
}

/* Header top row: Driver info (left) + GPS quality (right) */
.driver-status__header-top {
  @apply flex items-center justify-between;
  @apply pb-3 mb-3;
  @apply border-b border-gray-100;
}

/* Header bottom row: Status pill (left) + Last update (right) */
.driver-status__header-bottom {
  @apply flex items-center justify-between;
}

.driver-status__driver-info {
  @apply flex items-center gap-3;
  @apply flex-1 min-w-0;
}

.driver-status__avatar {
  @apply w-12 h-12 bg-gray-100 rounded-full flex items-center justify-center flex-shrink-0;
}

.driver-status__avatar svg {
  @apply w-6 h-6 text-gray-500;
}

.driver-status__name {
  @apply text-base font-bold text-gray-900;
}

.driver-status__zone {
  @apply flex items-center gap-1 text-sm text-gray-500;
}

.driver-status__zone-icon {
  @apply w-4 h-4 flex-shrink-0;
}

.driver-status__status-row {
  @apply flex items-center justify-between w-full;
}

.driver-status__status-dot {
  @apply w-2 h-2 rounded-full bg-current inline-block;
}

.driver-status__last-update {
  @apply text-sm text-gray-500;
}

.driver-status__content {
  @apply flex-1;
}

.driver-status__footer {
  @apply mt-8;
}

.logout-button {
  @apply flex items-center justify-center gap-2;
  @apply w-full py-4 px-4;
  @apply bg-white hover:bg-gray-50 rounded-xl;
  @apply text-red-600 font-semibold;
  @apply border-2 border-red-200 hover:border-red-300;
  @apply transition-all cursor-pointer;
  @apply active:scale-95;
}

.logout-button svg {
  @apply w-5 h-5 text-red-500;
}

/* ============================================
   GPS Quality Indicator
   ============================================ */

.gps-quality {
  @apply flex items-center gap-2;
  @apply px-3 py-2 rounded-lg;
  @apply text-sm font-semibold;
}

.gps-quality--excellent {
  @apply bg-green-100 text-green-800;
}

.gps-quality--good {
  @apply bg-green-50 text-green-700;
}

.gps-quality--fair {
  @apply bg-yellow-100 text-yellow-800;
}

.gps-quality--poor {
  @apply bg-red-100 text-red-800;
}

.gps-quality--unknown {
  @apply bg-gray-100 text-gray-600;
}

.gps-quality__icon {
  @apply text-lg;
}

.gps-quality__text {
  @apply font-medium;
}

/* ============================================
   Status Button Grid
   ============================================ */

.status-grid {
  @apply grid grid-cols-2 gap-4;
}

/* Status buttons container - main toggle + secondary actions */
.status-buttons {
  @apply space-y-4;
}

/* Main toggle button (Connect/Disconnect) - full width */
.status-button--toggle {
  @apply w-full;
}

.status-button--connect {
  @apply border-green-300 bg-green-50;
}

.status-button--connect .status-button__icon {
  @apply text-green-600;
}

.status-button--connect .status-button__text {
  @apply text-green-800;
}

.status-button--disconnect {
  @apply border-gray-300 bg-gray-50;
}

.status-button--disconnect .status-button__icon {
  @apply text-gray-600;
}

.status-button--disconnect .status-button__text {
  @apply text-gray-800;
}

/* Secondary actions row (Break + Emergency) - 2 column grid */
.status-buttons__secondary {
  @apply grid grid-cols-2 gap-4;
}

.status-button {
  @apply flex flex-col items-center justify-center;
  @apply p-6 rounded-xl;
  @apply bg-white border-2 border-gray-200;
  @apply transition-all duration-200;
  @apply active:scale-95;
  /* Minimum touch target size for accessibility */
  min-height: 120px;
  touch-action: manipulation;
}

.status-button:active {
  @apply shadow-inner;
}

.status-button--online {
  @apply border-green-200 hover:bg-green-50;
}

.status-button--online.status-button--active {
  @apply bg-green-100 border-green-400;
}

.status-button--offline {
  @apply border-gray-200 hover:bg-gray-50;
}

.status-button--offline.status-button--active {
  @apply bg-gray-100 border-gray-400;
}

.status-button--break {
  @apply border-yellow-200 hover:bg-yellow-50;
}

.status-button--break.status-button--active {
  @apply bg-yellow-100 border-yellow-400;
}

.status-button--emergency {
  @apply bg-red-500 border-red-600 hover:bg-red-600;
}

.status-button--emergency .status-button__icon,
.status-button--emergency .status-button__text {
  @apply text-white;
}

.status-button__icon {
  @apply mb-3;
}

.status-button__icon svg {
  @apply w-12 h-12;
}

.status-button--online .status-button__icon {
  @apply text-green-600;
}

.status-button--offline .status-button__icon {
  @apply text-gray-600;
}

.status-button--break .status-button__icon {
  @apply text-yellow-600;
}

.status-button__text {
  @apply text-sm font-bold text-center;
}

.status-button--online .status-button__text {
  @apply text-green-800;
}

.status-button--offline .status-button__text {
  @apply text-gray-800;
}

.status-button--break .status-button__text {
  @apply text-yellow-800;
}

/* ============================================
   Info Cards
   ============================================ */

.driver-status__info {
  @apply space-y-3;
}

.info-card {
  @apply flex justify-between items-center;
  @apply p-4 bg-white rounded-lg shadow-sm;
}

.info-card__label {
  @apply text-sm text-gray-600 font-medium;
}

.info-card__value {
  @apply text-base font-semibold text-gray-900;
}

/* ============================================
   Deep Link Success Page
   ============================================ */

.deep-link-success {
  @apply min-h-screen flex items-center justify-center;
  @apply bg-gradient-to-b from-green-50 to-white;
}

.deep-link-success__container {
  @apply text-center px-6;
}

.deep-link-success__icon {
  @apply text-6xl mb-4;
  @apply text-green-500;
}

.deep-link-success__title {
  @apply text-2xl font-bold text-gray-900 mb-3;
}

.deep-link-success__message {
  @apply text-base text-gray-600 mb-6;
}

.deep-link-success__loader {
  @apply flex justify-center;
}

/* ============================================
   Deep Link Error Page
   ============================================ */

.deep-link-error {
  @apply min-h-screen flex items-center justify-center;
  @apply bg-gradient-to-b from-red-50 to-white;
}

.deep-link-error__container {
  @apply text-center px-6;
}

.deep-link-error__icon {
  @apply text-6xl mb-4;
  @apply text-red-500;
}

.deep-link-error__title {
  @apply text-2xl font-bold text-gray-900 mb-3;
}

.deep-link-error__message {
  @apply text-base text-gray-600 mb-6;
}

.deep-link-error__actions {
  @apply mt-6;
}

.deep-link-error__help {
  @apply text-sm text-gray-500;
}

/* ============================================
   Error Messages - Responsive Design
   ============================================ */

.error {
  @apply flex items-center;
  @apply gap-2 sm:gap-3;
  @apply p-3 sm:p-4;
  @apply bg-red-50 border border-red-200 rounded-lg;
  @apply mb-4;
}

.error__icon {
  @apply text-xl sm:text-2xl;
  @apply text-red-500;
  @apply flex-shrink-0;
}

.error__message {
  @apply text-sm font-medium text-red-800;
}

/* ============================================
   Loader Animation
   ============================================ */

.loader {
  @apply border-4 border-gray-200 rounded-full;
  @apply w-12 h-12;
  border-top-color: #10b981; /* green-500 */
  animation: spin 1s linear infinite;
}

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

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

/* ============================================
   Native Action Bridge (Hidden)
   ============================================ */

.native-action {
  @apply hidden;
}

/* ============================================
   Dark Mode Support (uses Tailwind dark:)
   ============================================ */

@media (prefers-color-scheme: dark) {
  .mobile-body {
    @apply bg-gray-900;
  }

  .driver-status__header,
  .info-card,
  .status-button {
    @apply bg-gray-800 border-gray-700;
  }

  .driver-status__title,
  .info-card__value {
    @apply text-white;
  }

  .info-card__label {
    @apply text-gray-400;
  }

  .status-button--online {
    @apply border-green-700;
  }

  .status-button--offline {
    @apply border-gray-600;
  }

  .status-button--break {
    @apply border-yellow-700;
  }
}

/* ============================================
   NOTE: Safe-area insets now handled inline in layout
   See layouts/application.html.erb for conditional safe-area support
   ============================================ */

/* ============================================
   Welcome Page - Plain CSS (no @apply)
   ============================================ */

.welcome {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: #f9fafb; /* gray-50 */
}

.welcome__content {
  flex: 1;
  padding: 2rem 1.25rem;
  color: #111827; /* gray-900 */
  max-width: 28rem;
  margin: 0 auto;
  width: 100%;
}

.welcome__heading {
  font-weight: 700;
  text-align: center;
  color: #111827;
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.welcome__subheading {
  text-align: center;
  color: #6b7280; /* gray-500 */
  font-size: 0.875rem;
  margin-bottom: 2rem;
}

.welcome__text {
  color: #4b5563; /* gray-600 */
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

/* Welcome page sections - Card style */
.welcome__section {
  background-color: white;
  border-radius: 1rem;
  padding: 1.25rem;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  border: 1px solid #f3f4f6; /* gray-100 */
}

.welcome__section-title {
  font-weight: 600;
  color: #111827;
  font-size: 1.125rem;
  margin-bottom: 0.5rem;
}

/* Divider between sections */
.welcome__divider {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 1.5rem 0;
}

.welcome__divider::before,
.welcome__divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid #d1d5db; /* gray-300 */
}

.welcome__divider-text {
  padding: 0 1rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: #9ca3af; /* gray-400 */
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Phone form container */
.welcome__phone-form {
  margin-top: 1rem;
}

/* Hint text below form */
.welcome__hint {
  text-align: center;
  font-size: 0.75rem;
  color: #6b7280;
  margin-top: 1rem;
}

/* Registration button */
.welcome__register-btn {
  margin-top: 1rem;
}

/* Legacy styles for steps (if used) */
.welcome__steps {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.welcome__step {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background-color: #f9fafb;
  border-radius: 0.75rem;
}

.welcome__step-number {
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #22c55e; /* green-500 */
  color: white;
  border-radius: 9999px;
  font-weight: 700;
  font-size: 0.875rem;
  flex-shrink: 0;
}

.welcome__step-text {
  color: #1f2937; /* gray-800 */
  font-weight: 500;
  font-size: 0.875rem;
}

.welcome__button {
  display: block;
  width: 100%;
  padding: 0.75rem 1rem;
  background-color: #22c55e;
  color: white;
  text-align: center;
  font-weight: 700;
  font-size: 1rem;
  border-radius: 0.75rem;
  transition: background-color 0.2s;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  min-height: 48px;
  border: none;
  cursor: pointer;
}

.welcome__button:hover {
  background-color: #16a34a; /* green-600 */
}

.welcome__footer {
  background-color: white;
  padding: 0 1rem 1.5rem;
}

.welcome__footer-text {
  text-align: center;
  font-size: 0.875rem;
  color: #6b7280;
}

/* ============================================
   Button Components - Plain CSS
   ============================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.5rem;
  font-weight: 500;
  transition: all 0.15s;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  min-height: 48px;
  touch-action: manipulation;
  border: none;
  cursor: pointer;
  text-decoration: none;
}

.btn:active {
  transform: scale(0.98);
}

.btn--primary {
  background-color: #16a34a; /* green-600 */
  color: white;
}

.btn--primary:hover {
  background-color: #15803d; /* green-700 */
}

.btn--primary:focus {
  outline: none;
  box-shadow: 0 0 0 2px white, 0 0 0 4px #22c55e;
}

.btn--secondary {
  background-color: #f3f4f6; /* gray-100 */
  color: #111827; /* gray-900 */
  border: 1px solid #e5e7eb; /* gray-200 */
}

.btn--secondary:hover {
  background-color: #e5e7eb; /* gray-200 */
}

.btn--secondary:focus {
  outline: none;
  box-shadow: 0 0 0 2px white, 0 0 0 4px #9ca3af;
}

.btn--full {
  width: 100%;
}

/* ============================================
   Form Components - Plain CSS
   ============================================ */

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

.form-label {
  display: block;
  font-weight: 500;
  color: #374151; /* gray-700 */
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
}

.form-label--required::after {
  color: #ef4444; /* red-500 */
  margin-left: 0.25rem;
  content: "*";
}

.form-input,
.form-select {
  width: 100%;
  border-radius: 0.5rem;
  border: 1px solid #d1d5db; /* gray-300 */
  padding: 0.75rem 1rem;
  min-height: 48px;
  font-size: 1rem;
  background-color: white;
  color: #111827;
}

.form-input:focus,
.form-select:focus {
  outline: none;
  border-color: #3b82f6; /* blue-500 */
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.form-input:disabled,
.form-select:disabled {
  background-color: #f3f4f6;
  color: #6b7280;
  cursor: not-allowed;
}

.form-help-text {
  font-size: 0.875rem;
  color: #6b7280;
  margin-top: 0.25rem;
}

.form-error-text {
  font-size: 0.875rem;
  color: #dc2626; /* red-600 */
  margin-top: 0.25rem;
}

.form-status {
  margin-top: 1rem;
  text-align: center;
  font-size: 0.875rem;
}

.form-status.success {
  color: #16a34a; /* green-600 */
  font-weight: 500;
}

.form-status.error {
  color: #dc2626; /* red-600 */
  font-weight: 500;
}

/* ============================================
   Country Autocomplete - Plain CSS
   ============================================ */

.country-autocomplete {
  position: relative;
}

.country-autocomplete__input {
  width: 100%;
  border-radius: 0.5rem;
  border: 1px solid #d1d5db;
  padding: 0.75rem 1rem;
  min-height: 48px;
  font-size: 1rem;
  background-color: white;
}

.country-autocomplete__input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.country-autocomplete__results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  max-height: 250px;
  overflow-y: auto;
  z-index: 50;
  margin-top: 0.25rem;
}

.country-autocomplete__item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 0.75rem 1rem;
  border: none;
  background: none;
  cursor: pointer;
  text-align: left;
  gap: 0.75rem;
  font-size: 0.9375rem;
}

.country-autocomplete__item:hover,
.country-autocomplete__item--highlighted {
  background-color: #f3f4f6;
}

.country-autocomplete__item:not(:last-child) {
  border-bottom: 1px solid #f3f4f6;
}

.country-autocomplete__flag {
  font-size: 1.25rem;
  flex-shrink: 0;
}

.country-autocomplete__name {
  flex: 1;
  color: #111827;
}

.country-autocomplete__prefix {
  color: #6b7280;
  font-size: 0.875rem;
}

.country-autocomplete__empty {
  padding: 1rem;
  text-align: center;
  color: #6b7280;
  font-size: 0.875rem;
}

/* Selected country display */
.country-selected {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 0.75rem 1rem;
  min-height: 48px;
  border: 1px solid #d1d5db;
  border-radius: 0.5rem;
  background: white;
  cursor: pointer;
  gap: 0.5rem;
  font-size: 1rem;
}

.country-selected:hover {
  border-color: #9ca3af;
}

.country-selected__flag {
  font-size: 1.25rem;
}

.country-selected__prefix {
  font-weight: 500;
  color: #111827;
}

.country-selected__change {
  margin-left: auto;
  font-size: 0.875rem;
  color: #3b82f6;
}
