/*
 * 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.
 */

/* Reset and Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.6;
  color: #333;
  background-color: #f5f5f5;
}

:focus-visible {
  outline: 3px solid #1f6fb2;
  outline-offset: 3px;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: -999px;
  background: #1f6fb2;
  color: #fff;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  z-index: 1001;
}

.skip-link:focus-visible {
  left: 1rem;
  top: 1rem;
}

/* Navigation */
.navbar {
  background-color: #1f2933;
  color: white;
  padding: 0.5rem 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.nav-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
}

.nav-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.nav-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.nav-title a {
  color: white;
  text-decoration: none;
}

.nav-title a:hover {
  opacity: 0.9;
}

.nav-links {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.nav-user {
  color: #ecf0f1;
  font-size: 0.95rem;
  opacity: 0.9;
}

.nav-link {
  color: white;
  text-decoration: none;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  transition: background-color 0.2s, color 0.2s;
  font-weight: 600;
}

.nav-link:hover {
  background-color: rgba(255,255,255,0.1);
}

.nav-links-open {
  transform: translateY(0);
  opacity: 1;
}

.nav-toggle {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.4);
  color: white;
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  display: none;
  align-items: center;
  gap: 0.35rem;
}

.nav-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(2px);
  z-index: 999;
  display: none;
}

.nav-backdrop-visible {
  display: block;
}

/* Main Content */
.main-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 2rem;
}

/* Flash Messages */
.flash {
  padding: 1rem;
  margin-bottom: 1.5rem;
  border-radius: 4px;
  font-weight: 500;
}

.flash-notice {
  background-color: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.flash-alert {
  background-color: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

/* Page Headers */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.page-header h2 {
  font-size: 2rem;
  color: #2c3e50;
}

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

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 4px;
  text-decoration: none;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  -webkit-tap-highlight-color: transparent; /* Remove tap highlight on mobile */
  touch-action: manipulation; /* Improve touch response */
}

.btn-primary {
  background-color: #3498db;
  color: white;
}

.btn-primary:hover {
  background-color: #2980b9;
}

.btn-secondary {
  background-color: #95a5a6;
  color: white;
}

.btn-secondary:hover {
  background-color: #7f8c8d;
}

.btn-danger {
  background-color: #e74c3c;
  color: white;
}

.btn-danger:hover {
  background-color: #c0392b;
}

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

.btn-wide {
  width: 100%;
}

/* Forms */
.form {
  background: white;
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  max-width: 600px;
}

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

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: #2c3e50;
}

.form-control {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 1rem;
  transition: border-color 0.2s;
}

.form-control:focus {
  outline: none;
  border-color: #3498db;
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.form-actions {
  display: flex;
  gap: 1rem;
  margin-top: 2rem;
}

.error-messages {
  background-color: #f8d7da;
  color: #721c24;
  padding: 1rem;
  border-radius: 4px;
  margin-bottom: 1.5rem;
}

.error-messages ul {
  margin-left: 1.5rem;
  margin-top: 0.5rem;
}

/* Login Page */
.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: calc(100vh - 200px);
}

.login-card {
  background: white;
  padding: 3rem;
  border-radius: 8px;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
  width: 100%;
  max-width: 400px;
}

.login-card h2 {
  margin-bottom: 2rem;
  text-align: center;
  color: #2c3e50;
}

.login-form {
  width: 100%;
}

/* Dashboard */
.dashboard-header {
  margin-bottom: 2rem;
}

.dashboard-header h2 {
  font-size: 2rem;
  color: #2c3e50;
}

.dashboard-subtitle {
  color: #5f6b77;
  margin-top: 0.35rem;
  font-size: 1rem;
}

.dashboard-section {
  background: white;
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  margin-bottom: 2rem;
}

.dashboard-section-secondary {
  margin-top: 1.5rem;
}

.dashboard-section h3 {
  margin-bottom: 1.5rem;
  color: #2c3e50;
  font-size: 1.5rem;
}

.dashboard-actions {
  display: flex;
  gap: 1rem;
  margin-top: 2rem;
}

.stacked-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Account Cards */
.accounts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1.5rem;
}

.account-card {
  background: #f8f9fa;
  padding: 1.5rem;
  border-radius: 8px;
  border: 1px solid #dee2e6;
  transition: transform 0.2s, box-shadow 0.2s;
}

.account-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.account-card h4 {
  margin-bottom: 0.5rem;
  color: #2c3e50;
}

.account-card h4 a {
  color: #2c3e50;
  text-decoration: none;
}

.account-card h4 a:hover {
  color: #3498db;
}

.account-owner {
  color: #7f8c8d;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.account-balance {
  font-size: 1.25rem;
  margin-bottom: 1rem;
}

.account-balance strong {
  color: #27ae60;
}

.account-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.account-detail-link {
  font-weight: 600;
  color: #1f6fb2;
  text-decoration: none;
}

.account-detail-link:hover {
  text-decoration: underline;
}

/* Tables */
.table-wrapper {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 1.5rem;
}

.accounts-table,
.transactions-table,
.users-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  min-width: 600px; /* Ensures table doesn't get too compressed */
}

.accounts-table thead,
.transactions-table thead,
.users-table thead {
  background-color: #2c3e50;
  color: white;
}

.accounts-table th,
.transactions-table th,
.users-table th {
  padding: 1rem;
  text-align: left;
  font-weight: 600;
}

.accounts-table td,
.transactions-table td,
.users-table td {
  padding: 1rem;
  border-top: 1px solid #dee2e6;
}

.accounts-table tbody tr:hover,
.transactions-table tbody tr:hover,
.users-table tbody tr:hover {
  background-color: #f8f9fa;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.875rem;
  font-weight: 500;
}

.badge-credit {
  background-color: #d4edda;
  color: #155724;
}

.badge-debit {
  background-color: #f8d7da;
  color: #721c24;
}

.badge-parent {
  background-color: #cfe2ff;
  color: #084298;
}

.badge-child {
  background-color: #fff3cd;
  color: #856404;
}

/* Account Details */
.account-details {
  background: white;
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  margin-bottom: 2rem;
}

.detail-card {
  padding: 1.5rem;
  background: #f8f9fa;
  border-radius: 4px;
}

.detail-card h3 {
  margin-bottom: 1rem;
  color: #2c3e50;
}

.detail-card p {
  margin-bottom: 0.5rem;
}

.account-actions {
  margin-top: 1.5rem;
}

.account-action-buttons {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}

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

.quick-transactions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.quick-transaction h4 {
  margin-bottom: 0.5rem;
  color: #2c3e50;
  font-size: 1.05rem;
}

.quick-transaction-form {
  background: #f5f7fa;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 0.75rem;
}

.quick-transaction-form label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: #4a5568;
}

.quick-transaction-row {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
}

.quick-transaction-row .form-control {
  flex: 1;
  min-width: 0;
}

/* Transactions Section */
.transactions-section {
  background: white;
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.section-header h3 {
  margin: 0;
  color: #2c3e50;
}

/* Bootstrap Page */
.bootstrap-container,
.bootstrap-message {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: calc(100vh - 200px);
  padding: 2rem;
}

.bootstrap-card,
.message-card {
  background: white;
  padding: 3rem;
  border-radius: 8px;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
  width: 100%;
  max-width: 500px;
}

.bootstrap-card h2,
.message-card h2 {
  margin-bottom: 1rem;
  text-align: center;
  color: #2c3e50;
}

.bootstrap-intro {
  text-align: center;
  color: #7f8c8d;
  margin-bottom: 2rem;
  line-height: 1.6;
}

.message-card p {
  text-align: center;
  margin-bottom: 1rem;
  color: #7f8c8d;
}

.message-card .btn {
  display: block;
  margin: 1.5rem auto 0;
  text-align: center;
}

.form-text {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.875rem;
  color: #6c757d;
}

.btn-large {
  width: 100%;
  padding: 1rem;
  font-size: 1.1rem;
}

/* Responsive Design */

/* Small laptops and tablets (900px) */
@media (max-width: 900px) {
  .nav-container {
    padding: 0 1rem;
    flex-direction: column;
    align-items: stretch;
  }

  .nav-brand {
    width: 100%;
  }

  .nav-links {
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    background: #121a24;
    flex-direction: column;
    align-items: stretch;
    padding: 1rem 1.25rem 1.5rem;
    transform: translateY(-120%);
    opacity: 0;
    transition: transform 0.25s ease, opacity 0.25s ease;
    max-height: calc(100vh - 56px);
    overflow-y: auto;
    gap: 0.5rem;
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
    z-index: 1001;
  }

  .navbar.is-open .nav-links {
    transform: translateY(0);
    opacity: 1;
  }

  .nav-title {
    font-size: 1.1rem;
  }

  .nav-toggle {
    display: inline-flex;
  }

  .nav-link {
    width: 100%;
    padding: 0.85rem 0.75rem;
  }

  .nav-user {
    width: 100%;
    text-align: left;
    padding: 0.35rem 0.75rem;
  }
}

/* Tablet and below (768px) */
@media (max-width: 768px) {
  .nav-container {
    gap: 0.5rem;
  }

  .main-content {
    padding: 1rem;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .page-header h2 {
    font-size: 1.5rem;
  }

  .page-actions {
    width: 100%;
    flex-direction: column;
  }

  .page-actions .btn {
    width: 100%;
  }

  .accounts-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-section {
    padding: 1.5rem;
  }

  .dashboard-section h3 {
    font-size: 1.25rem;
  }

  .dashboard-actions {
    flex-direction: column;
  }

  .dashboard-actions .btn {
    width: 100%;
  }

  .form {
    padding: 1.5rem;
  }

  .form-actions {
    flex-direction: column;
  }

  .form-actions .btn {
    width: 100%;
  }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .section-header .btn {
    width: 100%;
  }

  /* Make tables horizontally scrollable on mobile */
  .table-wrapper {
    margin-bottom: 1rem;
    -webkit-overflow-scrolling: touch;
  }

  .accounts-table,
  .transactions-table,
  .users-table {
    font-size: 0.875rem;
    min-width: 600px; /* Maintain minimum width for readability */
  }

  .accounts-table th,
  .transactions-table th,
  .users-table th,
  .accounts-table td,
  .transactions-table td,
  .users-table td {
    padding: 0.75rem 0.5rem;
    word-wrap: break-word;
  }

  .account-details {
    padding: 1.5rem;
  }

  .transactions-section {
    padding: 1.5rem;
  }

  .quick-transaction-row {
    flex-direction: column;
    align-items: stretch;
  }

  .quick-transaction-row .btn {
    width: 100%;
  }

  .account-action-buttons {
    flex-direction: column;
  }

  .login-card {
    padding: 2rem;
  }
}

/* Mobile phones (480px and below) */
@media (max-width: 480px) {
  .nav-container {
    padding: 0.75rem;
  }

  .nav-title {
    font-size: 1.1rem;
  }

  .nav-links {
    flex-direction: column;
    width: 100%;
    gap: 0.5rem;
  }

  .nav-link {
    width: 100%;
    text-align: center;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
  }

  .main-content {
    padding: 0.75rem;
  }

  .page-header h2 {
    font-size: 1.35rem;
  }

  .btn {
    padding: 0.875rem 1.25rem;
    font-size: 1rem;
    min-height: 44px; /* Better touch target */
  }

  .btn-sm {
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
    min-height: 36px;
  }

  .form {
    padding: 1.25rem;
    border-radius: 6px;
  }

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

  .form-control {
    padding: 0.875rem;
    font-size: 16px; /* Prevents zoom on iOS */
    min-height: 44px;
  }

  .dashboard-section {
    padding: 1.25rem;
  }

  .dashboard-section h3 {
    font-size: 1.15rem;
  }

  .account-card {
    padding: 1.25rem;
  }

  .account-card h4 {
    font-size: 1.1rem;
  }

  .account-card .btn {
    width: 100%;
  }

  .account-details {
    padding: 1.25rem;
  }

  .detail-card {
    padding: 1.25rem;
  }

  .transactions-section {
    padding: 1.25rem;
  }

  .section-header h3 {
    font-size: 1.15rem;
  }

  /* Optimize table display for very small screens */
  .accounts-table,
  .transactions-table,
  .users-table {
    font-size: 0.8rem;
    border-radius: 6px;
    min-width: 550px; /* Slightly smaller minimum for very small screens */
  }

  .accounts-table th,
  .transactions-table th,
  .users-table th,
  .accounts-table td,
  .transactions-table td,
  .users-table td {
    padding: 0.625rem 0.375rem;
    font-size: 0.8rem;
  }

  /* Stack action buttons in table cells */
  .accounts-table td .btn,
  .transactions-table td .btn,
  .users-table td .btn {
    display: block;
    width: 100%;
    margin-bottom: 0.25rem;
  }

  .accounts-table td .btn:last-child,
  .transactions-table td .btn:last-child,
  .users-table td .btn:last-child {
    margin-bottom: 0;
  }

  .login-card {
    padding: 1.5rem;
    margin: 1rem;
  }

  .login-card h2 {
    font-size: 1.5rem;
  }

  .bootstrap-card,
  .message-card {
    padding: 2rem 1.5rem;
    margin: 1rem;
  }

  .flash {
    padding: 0.875rem;
    font-size: 0.9rem;
  }

  .error-messages {
    padding: 0.875rem;
    font-size: 0.9rem;
  }
}

/* Compact stacked tables for mobile */
@media (max-width: 720px) {
  .transactions-table.mobile-stack {
    min-width: 0;
    width: 100%;
  }

  .transactions-table.mobile-stack thead {
    display: none;
  }

  .transactions-table.mobile-stack tbody tr {
    display: block;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 0.75rem 0.9rem;
    margin-bottom: 0.75rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    background: #fff;
  }

  .transactions-table.mobile-stack td {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    border: 0;
    padding: 0.35rem 0;
    font-size: 0.95rem;
  }

  .transactions-table.mobile-stack td::before {
    content: attr(data-label);
    font-weight: 600;
    color: #4a5568;
  }

  .transactions-table.mobile-stack .btn {
    width: auto;
  }

  .allowance-actions {
    flex-direction: column;
    align-items: stretch;
  }
}

/* Very small phones (360px and below) */
@media (max-width: 360px) {
  .nav-title {
    font-size: 1rem;
  }

  .page-header h2 {
    font-size: 1.25rem;
  }

  .accounts-table,
  .transactions-table,
  .users-table {
    font-size: 0.75rem;
    min-width: 500px; /* Even smaller for very small phones */
  }

  .accounts-table th,
  .transactions-table th,
  .users-table th,
  .accounts-table td,
  .transactions-table td,
  .users-table td {
    padding: 0.5rem 0.25rem;
  }

  .form {
    padding: 1rem;
  }

  .dashboard-section,
  .account-details,
  .transactions-section {
    padding: 1rem;
  }
}
