/* Global Styles - Resident Laundry App */
:root {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-card: #1e293b;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --border: #334155;
  --radius: 12px;
  --radius-sm: 8px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  -webkit-text-size-adjust: 100%;
}

::-webkit-scrollbar {
  display: none;
}

body {
  scrollbar-width: none;
}

/* View Containers */
#app {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 56px;
  padding-bottom: var(--safe-bottom);
}

.view {
  display: none;
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-top: var(--safe-top);
}

.view.active {
  display: flex;
  flex-direction: column;
}

.view-header {
  padding: 16px 20px 8px;
  flex-shrink: 0;
}

.view-title {
  font-size: 28px;
  font-weight: 700;
}

.view-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 20px 20px;
}

/* Tab Bar */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(56px + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 100;
}

.tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 10px;
  cursor: pointer;
  position: relative;
  padding: 4px 16px;
}

.tab-item.active {
  color: var(--accent);
}

.tab-icon {
  width: 24px;
  height: 24px;
}

.tab-label {
  font-weight: 500;
}

.badge-dot {
  position: absolute;
  top: 2px;
  right: 12px;
  width: 8px;
  height: 8px;
  background: var(--danger);
  border-radius: 50%;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal-content {
  background: var(--bg-secondary);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  padding: 24px 20px;
  padding-bottom: calc(24px + var(--safe-bottom));
}

/* Account Styles */
.account-section {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

.account-section:last-child {
  border-bottom: none;
}

.account-empty {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.5;
}

.account-profile {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.profile-field {
  display: flex;
  align-items: center;
  gap: 12px;
}

.profile-label {
  font-size: 13px;
  color: var(--text-secondary);
  width: 100px;
  flex-shrink: 0;
}

.profile-value {
  font-size: 16px;
  font-weight: 500;
  flex: 1;
}

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

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  width: 100%;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-link {
  background: none;
  color: var(--accent);
  padding: 4px 8px;
  font-size: 14px;
}

.btn-logout {
  background: var(--danger);
  color: #fff;
  width: 100%;
}

.btn-logout:hover:not(:disabled) {
  background: var(--danger-hover);
}

/* Forms */
.form-label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.form-input {
  display: block;
  width: 100%;
  padding: 12px 14px;
  font-size: 16px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  outline: none;
  margin-bottom: 12px;
}

.form-input:focus {
  border-color: var(--accent);
}

.form-error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 8px;
}


/* Notices */
.section-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.notices-empty {
  color: var(--text-secondary);
  font-size: 14px;
}

.notice-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.notice-item:last-child {
  border-bottom: none;
}

.notice-item.notice-unread {
  border-left: 3px solid var(--accent);
  padding-left: 12px;
}

.notice-message {
  font-size: 14px;
  line-height: 1.4;
  color: var(--text-primary);
  margin-bottom: 4px;
}

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

/* Loading Spinner */
.loading-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Tickets Section */
.tickets-section {
  padding: 0;
}

.tickets-header {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.tickets-title {
  font-size: 18px;
  font-weight: 600;
}

.tickets-submit-btn {
  width: 100%;
}

.tickets-locked {
  color: var(--text-secondary);
  font-size: 14px;
}

.tickets-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tickets-empty {
  color: var(--text-secondary);
  font-size: 14px;
}

.tickets-error {
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
}

/* Ticket Card */
.ticket-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
}

.ticket-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.ticket-category {
  font-size: 15px;
  font-weight: 600;
}

.ticket-status {
  font-size: 12px;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 12px;
}

.ticket-status.status-open {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
}

.ticket-status.status-responded {
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
}

.ticket-status.status-closed {
  background: rgba(148, 163, 184, 0.15);
  color: var(--text-secondary);
}

.ticket-description {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  line-height: 1.4;
}

.ticket-date {
  font-size: 12px;
  color: var(--text-secondary);
}

.ticket-response {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.ticket-response-label {
  font-size: 12px;
  font-weight: 600;
  color: #4ade80;
  display: block;
  margin-bottom: 4px;
}

.ticket-response-text {
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.4;
}

/* Ticket Modal */
.ticket-modal {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.ticket-modal-title {
  font-size: 20px;
  font-weight: 700;
}

.btn-modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 28px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.ticket-modal-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
}

.ticket-categories {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.ticket-category-btn {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  padding: 14px 12px;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.2s, background 0.2s;
}

.ticket-category-btn:hover {
  border-color: var(--accent);
}

.ticket-category-btn.selected {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.1);
  color: var(--accent);
}

.ticket-textarea-container {
  margin-top: 4px;
}

.ticket-textarea {
  min-height: 100px;
  resize: vertical;
  font-family: inherit;
}

.ticket-confirm-btn {
  margin-top: 8px;
}

/* Device Cards */
.device-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.device-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.available {
  background: #10b981;
}

.status-dot.running {
  background: #ef4444;
}

.status-dot.finished {
  background: #eab308;
}

.status-dot.offline {
  background: #6b7280;
}

.device-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  color: var(--text-secondary);
}

.device-name {
  font-size: 15px;
  font-weight: 600;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.device-status-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Progress Bar */
.progress-container {
  margin-top: 4px;
}

.progress-bar {
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 6px;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 1s linear;
}

.timer-text {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-secondary);
}

.countdown {
  font-weight: 600;
  color: var(--text-primary);
}

/* Cycle Complete */
.cycle-complete {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  color: #eab308;
}

.cycle-complete-icon {
  width: 20px;
  height: 20px;
}

.cycle-complete-text {
  font-size: 14px;
  font-weight: 600;
}

/* CTA Banner */
.cta-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(135deg, #1e3a5f 0%, #1e293b 100%);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  cursor: pointer;
  transition: border-color 0.2s;
}

.cta-banner:active {
  border-color: var(--accent);
}

.cta-icon {
  width: 32px;
  height: 32px;
  color: var(--accent);
  flex-shrink: 0;
}

.cta-text {
  flex: 1;
}

.cta-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.cta-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
}

.cta-arrow {
  width: 20px;
  height: 20px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

/* Error Message */
.error-message {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
}

.error-message p {
  margin-bottom: 16px;
  font-size: 14px;
}

.error-message button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
