/* BTH Messaging PWA - Redesign (Clean, Minimal, Warm) */

:root {
  /* Color Palette - Slate/Zinc inspired */
  --bg-app: #f8fafc; /* Slate 50 */
  --bg-card: #ffffff;
  --bg-subtle: #f1f5f9; /* Slate 100 */
  
  --text-primary: #1e293b; /* Slate 800 */
  --text-secondary: #64748b; /* Slate 500 */
  --text-tertiary: #94a3b8; /* Slate 400 */

  /* Accents */
  --primary: #4f46e5; /* Indigo 600 - Warm & Approachable */
  --primary-soft: #e0e7ff; /* Indigo 100 */
  --primary-dark: #4338ca; /* Indigo 700 */

  --success: #10b981; /* Emerald 500 */
  --success-soft: #d1fae5; /* Emerald 100 */
  
  --warning: #f59e0b; /* Amber 500 */
  --warning-soft: #fef3c7; /* Amber 100 */

  --danger: #ef4444; /* Red 500 */
  --danger-soft: #fee2e2; /* Red 100 */

  --border-color: #e2e8f0; /* Slate 200 */
  
  /* Layout */
  --max-width: 480px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);

  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-family);
  background: var(--bg-app);
  color: var(--text-primary);
  line-height: 1.5;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

#app {
  max-width: var(--max-width);
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg-app);
  position: relative;
  display: flex;
  flex-direction: column;
}

/* Typography */
h1, h2, h3 {
  margin: 0;
  font-weight: 600;
  color: var(--text-primary);
}

p {
  margin: 0 0 1rem 0;
}

/* Header */
.header {
  background: var(--bg-app);
  padding: 16px 20px;
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  backdrop-filter: blur(8px);
  background: rgba(248, 250, 252, 0.9);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}

.header.scrolled {
  border-bottom-color: var(--border-color);
}

.header h1 {
  font-size: 20px;
  letter-spacing: -0.02em;
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 8px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-icon:hover, .btn-icon:active {
  background: var(--bg-subtle);
  color: var(--text-primary);
}

.btn-icon.danger {
  color: var(--danger);
}

.btn-icon.danger:hover {
  background: var(--danger-soft);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 20px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.2s;
  text-decoration: none;
}

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

.btn-primary {
  background: var(--primary);
  color: white;
  width: 100%;
  box-shadow: 0 2px 4px rgba(79, 70, 229, 0.2);
}

.btn-secondary {
  background: white;
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-warning {
  background: var(--warning);
  color: white;
  box-shadow: 0 2px 4px rgba(245, 158, 11, 0.2);
}

.btn-warning:active {
  background: #d97706;
}

.btn-danger {
  background: var(--bg-card);
  color: var(--danger);
  border: 1px solid var(--danger-soft);
}

.btn-danger:active {
    background: var(--danger-soft);
}

.btn-link {
    background: none;
    color: var(--text-secondary);
    font-weight: 500;
    padding: 8px 16px;
}

/* Dashboard */
.dashboard-content {
  padding: 0 16px 80px 16px;
}

.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 24px 4px 12px 4px;
}

.sync-status {
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-secondary);
    font-size: 13px;
}

.sync-status button {
    color: var(--primary);
    background: none;
    border: none;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
}

/* Message List Cards */
.message-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-x: hidden; /* Prevent horizontal scrollbar on body when swiping */
}

.message-card {
  position: relative; /* For swipe context */
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  /* padding: 16px; removed padding here, moved to content */
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  cursor: pointer;
  /* transition: box-shadow 0.2s, transform 0.1s; removed transform to avoid conflict with swipe */
  transition: box-shadow 0.2s;
  overflow: hidden; /* Hide the background action initially */
  touch-action: pan-y; /* Allow vertical scroll, we handle horizontal */
  user-select: none;
}

.message-card-bg {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  left: 0;
  background-color: var(--danger);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 24px;
  color: white;
  z-index: 1;
}

.swipe-icon {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
  transform: translateX(20px);
  transition: transform 0.2s;
}

.message-card.swiping .swipe-icon {
    transform: translateX(0);
}

.message-card-content {
  position: relative;
  z-index: 2;
  background: var(--bg-card);
  padding: 16px;
  transition: transform 0.2s ease-out;
  height: 100%;
  width: 100%;
}

/* 
.message-card:active {
  transform: scale(0.99); 
} 
Removed scale on active to not interfere with swipe logic
*/

.message-card-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
}

.message-property {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.message-time {
  font-size: 12px;
  color: var(--text-tertiary);
}

.message-sender {
  font-weight: 600;
  font-size: 16px;
  margin-bottom: 4px;
  color: var(--text-primary);
}

.message-preview {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Review Screen */
.review-container {
    padding: 0 16px 100px 16px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.review-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.card-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--bg-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.card-content {
    padding: 16px;
    font-size: 15px;
    line-height: 1.6;
    color: var(--text-primary);
    white-space: pre-wrap;
}

.card-content.guest {
    color: var(--text-primary);
}

.card-content.suggestion {
    color: var(--text-primary);
    background: #fafafa;
}

.guest-meta {
    padding: 0 16px 12px 16px;
    font-size: 12px;
    color: var(--text-tertiary);
}

/* Action Bar */
.action-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--border-color);
    padding: 16px 20px 24px 20px;
    display: flex;
    gap: 12px;
    max-width: var(--max-width);
    margin: 0 auto;
    z-index: 50;
}

.action-bar .btn {
    flex: 1;
    height: 48px;
}

/* Feedback Form (Inline) */
.feedback-container {
    background: var(--bg-subtle);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-top: -10px; /* Pull up closer to card */
    border: 1px solid var(--border-color);
    animation: slideDown 0.3s ease;
}

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

.feedback-header {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.checkbox-group {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-secondary);
    cursor: pointer;
}

.checkbox-item input {
    accent-color: var(--primary);
    width: 18px;
    height: 18px;
}

textarea.edit-box {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 15px;
    line-height: 1.5;
    margin-bottom: 12px;
    resize: vertical;
    min-height: 120px;
}

textarea.edit-box:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

/* Login Screen */
.login-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 40px 24px;
}

.login-header {
    text-align: center;
    margin-bottom: 40px;
}

.login-header h1 {
    font-size: 24px;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 15px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 16px;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state h2 {
    font-size: 18px;
    margin-bottom: 8px;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-primary);
    color: white;
    padding: 12px 24px;
    border-radius: 50px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: floatUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    width: max-content;
    max-width: 90%;
}

@keyframes floatUp {
    from { opacity: 0; transform: translate(-50%, 20px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

/* Utilities */
.hidden { display: none !important; }

/* Loading Spinner */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Desktop Enhancements */
@media (min-width: 481px) {
    body {
        background-color: #cbd5e1; /* Slate 300 - clearly contrasting */
        background-image: radial-gradient(#94a3b8 1px, transparent 1px);
        background-size: 24px 24px;
        display: flex;
        justify-content: center;
        min-height: 100vh;
    }

    #app {
        width: 100%;
        max-width: var(--max-width);
        min-height: 100vh; /* Keep full height */
        box-shadow: 0 0 40px -5px rgba(0, 0, 0, 0.2);
        position: relative;
    }
}
