
:root {
  --background-color: #f4f4f9; /* Light grey background */
  --surface-color: #ffffff;   /* White for surfaces like cards and headers */
  --primary-color: #3f51b5;   /* Indigo - good contrast */
  --primary-variant-color: #7986cb; /* Lighter indigo */
  --on-background-color: #212121; /* Dark grey for text */
  --on-surface-color: #5f6368;  /* Medium grey for secondary text */
  --unread-indicator: #3f51b5;  /* Use primary color for unread dots */
  --border-color: #e0e0e0;    /* Light grey for borders */
  --status-connected: #4caf50; /* Green */
  --status-connecting: #ffab00; /* Amber */
  --status-disconnected: #f44336; /* Red */
  --status-approved: #4caf50; /* Green */
  --status-pending: #ffab00;  /* Amber */
  --status-rejected: #f44336; /* Red */
  --destructive-color: #d32f2f;
  --destructive-hover-color: #b71c1c;
}

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

html, body {
    width: 100%;
    height: 100%;
    font-family: 'Inter', sans-serif;
    background-color: var(--background-color);
    color: var(--on-background-color);
    overscroll-behavior: none;
}

#app-container {
    width: 100%;
    max-width: 450px; /* Simulate mobile screen */
    height: 100%;
    margin: 0 auto;
    background-color: var(--surface-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    border-left: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
}

.view {
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    padding: 24px;
    overflow-y: auto;
}

.view.active {
    display: flex;
}

header {
    text-align: center;
    margin-bottom: 32px;
    flex-shrink: 0;
}

header h2 {
    font-size: 1.8rem;
    margin-bottom: 8px;
}

header p {
    color: var(--on-surface-color);
}

.form-container {
    width: 100%;
}

.form-container.hidden {
    display: none;
}

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

.input-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--on-surface-color);
}

input[type="email"],
input[type="password"],
input[type="text"],
input[type="file"],
textarea {
    width: 100%;
    padding: 12px;
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--on-background-color);
    font-size: 1rem;
}

input[type="file"] {
    padding: 8px;
}

textarea {
    resize: vertical;
}

button {
    width: 100%;
    padding: 14px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
}

button:disabled {
    background-color: #cccccc;
    color: #888888;
    cursor: not-allowed;
}

button:hover:not(:disabled) {
    background-color: var(--primary-variant-color);
}

.button-destructive {
    background-color: var(--destructive-color);
}
.button-destructive:hover:not(:disabled) {
    background-color: var(--destructive-hover-color);
}


.auth-switch {
    text-align: center;
    margin-top: 20px;
    color: var(--on-surface-color);
}

.auth-switch a {
    color: var(--primary-color);
    font-weight: 500;
    cursor: pointer;
}

.error-message {
    background-color: #f8d7da;
    color: #721c24;
    padding: 12px;
    border: 1px solid #f5c6cb;
    border-radius: 8px;
    margin-bottom: 20px;
    display: none; /* Hidden by default */
    text-align: center;
    font-size: 0.9rem;
}

/* Landing Page Styles */
#landing-view {
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 32px;
    background: linear-gradient(135deg, #ffffff 0%, #f4f4f9 100%);
}

.landing-content {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#landing-image-logo {
    width: 100px;
    height: auto;
    margin-bottom: 16px;
    color: var(--primary-color);
}

#landing-text-logo {
    font-size: 42px;
    font-weight: 800;
    font-family: 'Inter', sans-serif;
    background: linear-gradient(135deg, #3f51b5 0%, #7986cb 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-fill-color: transparent;
    margin-bottom: 32px;
}


#landing-view p {
    font-size: 1.1rem;
    color: var(--on-surface-color);
    margin-bottom: 64px;
}

.landing-actions {
    width: 100%;
    max-width: 350px;
}

.landing-actions button {
    margin-bottom: 16px;
}

.button-secondary {
    background-color: transparent;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
}

.button-secondary:hover:not(:disabled) {
    background-color: var(--primary-color);
    color: white;
}

/* Auth View adjustments */
#auth-view {
    justify-content: center;
    position: relative;
}

.back-button {
    position: absolute;
    top: 16px;
    left: 16px;
    background: none;
    border: none;
    color: var(--on-surface-color);
    font-size: 1.5rem;
    width: auto;
    padding: 4px 8px;
    cursor: pointer;
}
.back-button:hover {
    color: var(--primary-color);
    background: none;
}


/* Main App View */
#main-view {
    padding: 0;
}

#main-header {
    padding: 16px;
    text-align: center;
    background-color: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

#status-bar {
    color: white;
    padding: 8px 16px;
    text-align: center;
    font-weight: 500;
    font-size: 0.9rem;
    display: none; /* Hidden by default */
    flex-shrink: 0;
    transition: background-color 0.3s ease;
}

#status-bar.active {
    display: block;
    cursor: pointer;
}

#status-bar.connecting {
    display: block;
    background-color: var(--status-connecting);
    cursor: default;
}

#status-bar.connected {
    display: block;
    background-color: var(--status-connected);
    cursor: default;
}

#status-bar.disconnected {
    display: block;
    background-color: var(--status-disconnected);
    cursor: default;
}

#status-bar.has-unread {
    background-color: var(--primary-variant-color);
}

#content-container {
    flex-grow: 1;
    overflow-y: auto;
    position: relative;
    background-color: var(--background-color);
}

.sub-view {
    display: none;
    width: 100%;
    height: 100%;
    padding: 16px;
    overflow-y: auto;
}

.sub-view.active {
    display: block;
}

#nav-bar {
    display: flex;
    justify-content: space-around;
    width: 100%;
    padding: 8px 0;
    background-color: var(--surface-color);
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

.nav-button {
    background: none;
    border: none;
    color: var(--on-surface-color);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    border-radius: 8px;
    transition: color 0.2s;
    width: auto;
    flex-grow: 1;
}

.nav-button svg {
    width: 24px;
    height: 24px;
}

.nav-button.active {
    color: var(--primary-color);
}

/* Home View */
#home-view.active {
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.home-content h2 {
    font-size: 2rem;
    margin-bottom: 16px;
}

.home-content p {
    color: var(--on-surface-color);
    margin-bottom: 32px;
}

.quick-actions {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
    max-width: 250px;
    margin: 0 auto;
}

.quick-action-button {
    background-color: transparent;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
}

.quick-action-button:hover {
    background-color: var(--primary-color);
    color: white;
}

/* Message List */
.message-list {
    list-style: none;
    background-color: var(--surface-color);
    border-radius: 8px;
    overflow: hidden;
}

.message-list li {
    padding: 0;
    border-bottom: 1px solid var(--border-color);
    position: relative;
}

.message-list li:last-child {
    border-bottom: none;
}

.swipe-container {
    position: relative;
    width: 100%;
    background-color: var(--destructive-color);
    overflow: hidden;
}

.swipe-actions {
    position: absolute;
    top: 0;
    right: 0;
    height: 100%;
    display: flex;
    align-items: center;
}

.delete-swipe-button {
    width: 80px;
    height: 100%;
    background-color: var(--destructive-color);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    font-size: 0.9rem;
}

.delete-swipe-button svg {
    width: 24px;
    height: 24px;
}

.swipe-content {
    background-color: var(--surface-color);
    position: relative;
    transition: transform 0.3s ease;
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    cursor: pointer;
    touch-action: pan-y; /* Allow vertical scroll */
}

.swipe-content:hover {
    background-color: var(--background-color);
}

#inbox-view .swipe-content {
    padding-left: 24px; /* Space for unread indicator */
}

.message-list li.unread .swipe-content .message-sender {
    font-weight: 700;
    color: var(--on-background-color);
}
.message-list li.unread .swipe-content .message-preview {
    font-weight: 500;
    color: var(--on-background-color);
}
.message-list li.unread::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 21px; /* Vertically align with first line of text */
    transform: translateY(-50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--unread-indicator);
    z-index: 2; /* Above swipe content */
}

.message-content {
    flex-grow: 1;
    min-width: 0; /* Prevents long text from pushing meta content off-screen */
}

.message-meta {
    flex-shrink: 0;
    text-align: right;
}

.message-sender, .message-recipient {
    font-size: 1.1rem;
    margin-bottom: 4px;
    color: var(--on-background-color);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
}
.message-preview {
    color: var(--on-surface-color);
    word-break: break-word; /* Allow long words to wrap */
}
.message-time {
    font-size: 0.8rem;
    color: var(--on-surface-color);
    white-space: nowrap;
}

.message-status {
    font-size: 0.8rem;
    font-weight: 500;
    margin-top: 4px;
}
.message-status.sent {
    color: var(--on-surface-color);
}
.message-status.read {
    color: var(--primary-color);
}

/* Verified Badge */
.verified-badge {
    display: inline-block;
    width: 20px;
    height: 20px;
    background-color: var(--primary-color);
    color: white;
    border-radius: 50%;
    flex-shrink: 0;
}
.verified-badge svg {
    width: 20px;
    height: 20px;
    position: relative;
    top: -3px;
    left: 0px;
}


/* Message Detail View */
#message-detail-view .detail-header {
    margin-bottom: 24px;
}
#back-to-list-button {
    width: auto;
    background: none;
    border: none;
    color: var(--primary-color);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    padding: 4px 8px;
}
#message-detail-view .detail-meta {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 8px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}
#detail-contact-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

#message-detail-view .detail-contact {
    font-size: 1.2rem;
    font-weight: 600;
}
#message-detail-view .detail-time {
    font-size: 0.9rem;
    color: var(--on-surface-color);
}
#message-detail-view .detail-body {
    font-size: 1rem;
    line-height: 1.6;
    white-space: pre-wrap; /* Preserve line breaks */
    color: var(--on-background-color);
    margin-bottom: 24px;
}

#map-link-container {
    margin-bottom: 24px;
}
#map-link-container.hidden {
    display: none;
}
#map-link-container a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}
#map-link-container a:hover {
    text-decoration: underline;
}

.detail-actions {
    margin-top: auto;
    padding-top: 16px;
    display: flex;
    gap: 16px;
}
.detail-actions button.hidden {
    display: none;
}


/* Settings */
.settings-list {
    list-style: none;
    margin-bottom: 24px;
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}
.settings-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}
.settings-list li:last-child {
    border-bottom: none;
}
.setting-value {
    color: var(--on-surface-color);
    font-weight: 500;
}

.setting-value.unverified-data {
    color: var(--on-surface-color);
    font-style: italic;
}

.settings-section {
    margin-top: 32px;
}
.settings-section h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--on-surface-color);
    margin-bottom: 12px;
    padding-left: 4px;
}


#logout-button {
    background-color: var(--destructive-color);
    margin-top: 32px;
}
#logout-button:hover {
    background-color: var(--destructive-hover-color);
}

/* Toggle Switch CSS */
.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 28px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: .4s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: .4s;
}

input:checked + .slider {
  background-color: var(--primary-color);
}

input:focus + .slider {
  box-shadow: 0 0 1px var(--primary-color);
}

input:checked + .slider:before {
  transform: translateX(22px);
}

.slider.round {
  border-radius: 34px;
}

.slider.round:before {
  border-radius: 50%;
}

/* Verification View & Statuses */
#verification-process-view {
    justify-content: flex-start;
}

.verification-card {
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 24px;
}
.verification-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.verification-card-header h3 {
    font-size: 1.2rem;
}
.verification-card-desc {
    color: var(--on-surface-color);
    margin-bottom: 16px;
}
.verification-form {
    display: flex;
    gap: 12px;
}
.verification-form input {
    flex-grow: 1;
}
.verification-form button {
    flex-shrink: 0;
    width: auto;
    padding: 10px 16px;
    font-size: 0.9rem;
}
.verification-note {
    text-align: center;
    color: var(--on-surface-color);
    font-size: 0.9rem;
    margin-bottom: 16px;
}


.status-badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    color: white;
    text-transform: capitalize;
}
.status-badge.not-submitted, .status-badge.not-verified {
    background-color: var(--on-surface-color);
}
.status-badge.pending {
    background-color: var(--status-pending);
}
.status-badge.approved, .status-badge.verified {
    background-color: var(--status-approved);
}
.status-badge.rejected {
    background-color: var(--status-rejected);
}
