/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

@tailwind base;
@tailwind components;
@tailwind utilities;

/* Custom styles */
@layer base {
  :root {
    --primary: #3D9970;
    --text: #333333;
    --light-bg: #F7F7F7;
    --border: #E0E0E0;
  }

  /* Prevent horizontal scroll on mobile */
  html, body {
    overflow-x: hidden;
    max-width: 100vw;
  }
}

/* Common components */
@layer components {
  /* Hide number input spinners */
  input[type="number"]::-webkit-outer-spin-button,
  input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
  }

  input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
  }

  /* Seamless editing - make form fields look like text */
  .field-as-text {
    border: none;
    background: transparent;
    padding: 2px 4px;
    margin: -2px -4px;
    font-size: inherit;
    font-weight: inherit;
    color: inherit;
    outline: none;
    cursor: text;
    width: auto;
    min-width: 60px;
    transition: all 0.15s ease;
    border-radius: 4px;
  }

  /* Focused state - subtle indication */
  .field-as-text:focus {
    background: rgba(0, 0, 0, 0.02);
    border: none;
    outline: none;
  }

  /* Description field (textarea) */
  .description-field {
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.4;
  }

  /* Amount field */
  .amount-field {
    font-size: 1rem;
    font-weight: 600;
    text-align: right;
    width: 100px;
  }

  .amount-field.mode-expense {
    color: rgb(220, 38, 38);
  }

  .amount-field.mode-income {
    color: rgb(16, 185, 129);
  }

  /* Actions panel - slides in/out */
  .actions-panel {
    overflow: hidden;
    transition: max-height 0.2s ease-out;
  }

  .actions-panel.visible {
    max-height: 120px;
  }

  /* Saving state */
  .saving .field-as-text:focus {
    animation: pulse-saving 1s ease-in-out infinite;
  }

  @keyframes pulse-saving {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
  }

  /* Success flash */
  @keyframes flash-success {
    0%, 100% { background-color: transparent; }
    50% { background-color: rgba(16, 185, 129, 0.15); }
  }

  .save-success {
    animation: flash-success 0.6s ease;
  }

  /* Error state */
  .field-error {
    border-color: rgb(239, 68, 68) !important;
    background: rgba(239, 68, 68, 0.05) !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1) !important;
  }

  /* Mobile: Numeric input */
  @media (max-width: 768px) {
    /* Prevent iOS zoom on focus - font-size must be >= 16px */
    .description-field {
      font-size: 1rem; /* 16px - prevents iOS auto-zoom */
    }

    .amount-field {
      font-size: 1.125rem; /* 18px */
    }

    .field-as-text:focus {
      padding: 8px 12px;
      margin: -10px -14px;
    }
  }

  /* Chat message animations */
  .chat-message {
    animation: slideInMessage 0.2s ease-out;
  }

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

  /* View transitions for groups */
  ::view-transition-old(group-*),
  ::view-transition-new(group-*) {
    animation-duration: 0.15s;
  }

}
