@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-card: #1e293b;
  --bg-glass: rgba(30, 41, 59, 0.85);
  --border-color: rgba(255, 255, 255, 0.1);
  --border-active: #3b82f6;
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --accent-blue: #3b82f6;
  --accent-cyan: #06b6d4;
  --accent-teal: #14b8a6;
  --accent-amber: #f59e0b;
  --accent-emerald: #10b981;
  --accent-rose: #f43f5e;
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.35);
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-primary);
  background-image: 
    radial-gradient(at 10% 10%, rgba(59, 130, 246, 0.15) 0px, transparent 50%),
    radial-gradient(at 90% 90%, rgba(20, 184, 166, 0.12) 0px, transparent 50%),
    radial-gradient(at 50% 50%, rgba(245, 158, 11, 0.08) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Typography */
h1, h2, h3, h4, .brand-title {
  font-family: 'Outfit', sans-serif;
  letter-spacing: -0.02em;
}

/* Layout Header */
.app-header {
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 0.85rem 1.5rem;
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--text-main);
}

.brand-icon {
  font-size: 1.6rem;
  background: linear-gradient(135deg, #f59e0b, #ec4899);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
}

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

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  touch-action: manipulation;
  min-height: 38px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-blue), #2563eb);
  color: #fff;
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.35);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  border-color: var(--border-color);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
}

.btn-danger {
  background: rgba(244, 63, 94, 0.15);
  color: #fca5a5;
  border-color: rgba(244, 63, 94, 0.3);
}

.btn-danger:hover {
  background: rgba(244, 63, 94, 0.3);
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
  min-height: 34px;
}

/* Main Container */
.main-container {
  max-width: 1200px;
  width: 100%;
  margin: 1.25rem auto;
  padding: 0 1.25rem;
  flex: 1;
}

/* Messages / Alerts */
.messages-container {
  margin-bottom: 1.25rem;
}

.alert {
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-md);
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid transparent;
  animation: fadeIn 0.3s ease;
}

.alert-success {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.3);
  color: #6ee7b7;
}

.alert-error {
  background: rgba(244, 63, 94, 0.15);
  border-color: rgba(244, 63, 94, 0.3);
  color: #fca5a5;
}

.alert-info {
  background: rgba(59, 130, 246, 0.15);
  border-color: rgba(59, 130, 246, 0.3);
  color: #93c5fd;
}

/* Footer Styling */
.app-footer {
  margin-top: auto;
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
  padding: 1.25rem 1.5rem;
}

.footer-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.footer-text {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.footer-text a {
  color: var(--accent-cyan);
  text-decoration: none;
}

.footer-text a:hover {
  text-decoration: underline;
}

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

.login-card {
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2.25rem 1.75rem;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.login-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

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

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 0.4rem;
  color: var(--text-muted);
}

.form-control {
  width: 100%;
  padding: 0.75rem 0.9rem;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 1rem; /* 16px to prevent iOS zoom */
  outline: none;
  transition: border-color 0.2s ease;
}

.form-control:focus {
  border-color: var(--border-active);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

/* Calendar Toolbar & Stats */
.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.month-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.month-title {
  font-size: 1.5rem;
  font-weight: 700;
  min-width: 170px;
  text-align: center;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.15rem;
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  margin-top: 0.25rem;
}

.stat-sub {
  font-size: 0.775rem;
  color: var(--text-dim);
  margin-top: 0.25rem;
}

/* Calendar Grid */
.calendar-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-lg);
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.4rem;
}

.weekday-header {
  text-align: center;
  font-weight: 600;
  font-size: 0.825rem;
  color: var(--text-muted);
  padding: 0.4rem 0;
}

.calendar-day {
  min-height: 95px;
  background: rgba(15, 23, 42, 0.4);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.4rem 0.45rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: all 0.2s ease;
  cursor: pointer;
  position: relative;
}

.calendar-day:hover {
  border-color: rgba(255, 255, 255, 0.25);
  background: rgba(15, 23, 42, 0.75);
}

.calendar-day.other-month {
  opacity: 0.35;
}

.calendar-day.is-today {
  border-color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.08);
}

.day-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.day-num {
  font-weight: 600;
  font-size: 0.9rem;
}

.today-pill {
  font-size: 0.6rem;
  background: var(--accent-cyan);
  color: #000;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 4px;
}

/* Booking Badges */
.booking-badge {
  margin-top: 0.25rem;
  padding: 0.35rem 0.45rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  border: 1px solid transparent;
}

.booking-badge.paid {
  background: rgba(16, 185, 129, 0.2);
  border-color: rgba(16, 185, 129, 0.4);
  color: #6ee7b7;
}

.booking-badge.unpaid {
  background: rgba(245, 158, 11, 0.2);
  border-color: rgba(245, 158, 11, 0.4);
  color: #fcd34d;
}

.badge-renter {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge-details {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.7rem;
  opacity: 0.9;
}

/* Modal Overlay & Responsive Dialogs */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-overlay.active {
  display: flex;
  animation: fadeIn 0.2s ease;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.5rem;
  box-shadow: var(--shadow-lg);
}

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

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.2rem 0.5rem;
}

.modal-close:hover {
  color: #fff;
}

.switch-label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
}

.switch-input {
  width: 1.2rem;
  height: 1.2rem;
  accent-color: var(--accent-emerald);
}

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

/* =======================================================
   MOBILE & TABLET RESPONSIVE MEDIA QUERIES
   ======================================================= */

@media (max-width: 768px) {
  .app-header {
    padding: 0.75rem 1rem;
  }

  .header-container {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .nav-actions {
    justify-content: space-between;
    width: 100%;
  }

  .main-container {
    padding: 0 0.85rem;
    margin: 1rem auto;
  }

  .calendar-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.85rem;
  }

  .month-nav {
    justify-content: space-between;
    width: 100%;
  }

  .month-title {
    font-size: 1.35rem;
    min-width: auto;
  }

  .stats-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .calendar-card {
    padding: 0.75rem 0.5rem;
  }

  .calendar-grid {
    gap: 0.25rem;
  }

  .weekday-header {
    font-size: 0.75rem;
    padding: 0.3rem 0;
  }

  .calendar-day {
    min-height: 65px;
    padding: 0.25rem;
    border-radius: 6px;
  }

  .day-num {
    font-size: 0.8rem;
  }

  .today-pill {
    font-size: 0.55rem;
    padding: 0px 3px;
  }

  .booking-badge {
    padding: 0.2rem 0.3rem;
    font-size: 0.7rem;
    margin-top: 0.15rem;
  }

  .badge-details {
    display: none; /* Hide detailed row inside cell to fit nicely on mobile screens */
  }

  /* Modals on Mobile */
  .modal-overlay {
    padding: 0.5rem;
  }

  .modal-card {
    padding: 1.25rem 1rem;
    border-radius: var(--radius-md);
  }

  /* Form 2-column grids collapse to single column on mobile */
  form div[style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
    gap: 0.5rem !important;
  }
}

@media (max-width: 480px) {
  .brand-title {
    font-size: 1.1rem;
  }

  .calendar-day {
    min-height: 55px;
  }

  .booking-badge {
    font-size: 0.65rem;
  }
}
