/* Core Variables & Global Reset */
:root {
    --color-bg-dark: #1a0d33;
    --color-bg-light: #2c1a4e;
    --color-primary: #4b1e9c;
    --color-accent: #ffb700;
    --color-text-light: #f4f4f4;
    --color-text-muted: #a0a0a0;
    --color-danger: #d32f2f;
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --border-radius: 8px;
    --border-radius-sm: 4px;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.2);
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body, #app-container, .view {
    height: 100%;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--color-bg-dark);
    color: var(--color-text-light);
    overflow-x: hidden;
}

/* Main Layout */
body {
    display: flex;
    flex-direction: column;
}

#app-container {
    flex-grow: 1;
    position: relative;
    display: flex;
    flex-direction: column;
}

.view {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    padding-bottom: 80px; /* Space for bottom nav and sticky footer */
    will-change: transform, opacity;
}

.hidden {
    display: none;
}

/* Top and Bottom Navigation */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-md);
    background: linear-gradient(180deg, rgba(75, 30, 156, 0.5) 0%, rgba(75, 30, 156, 0) 100%);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    position: sticky;
    top: 0;
    z-index: 500;
}

#bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 70px;
    display: flex;
    justify-content: space-around;
    align-items: center;
    background-color: var(--color-bg-light);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 -4px 6px rgba(0, 0, 0, 0.2);
    z-index: 1000;
}

#bottom-nav button {
    flex: 1;
    height: 100%;
    background: none;
    border: none;
    color: var(--color-text-muted);
    font-size: 0.8em;
    font-weight: 500;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-xs);
    transition: color 0.2s ease, transform 0.2s ease;
    cursor: pointer;
}

#bottom-nav button:hover, #bottom-nav button.active {
    color: var(--color-accent);
}

.sticky-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-between;
    padding: var(--spacing-md);
    background-color: var(--color-bg-light);
    box-shadow: 0 -4px 6px rgba(0, 0, 0, 0.2);
    z-index: 900;
}

/* Global Components */
.view-title {
    margin: 0;
    font-size: 1.5em;
    font-weight: 600;
}

.button {
    padding: var(--spacing-sm) var(--spacing-md);
    border: none;
    border-radius: var(--border-radius);
    font-size: 1em;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.1s ease;
    min-width: 100px;
    text-align: center;
}

.button:active {
    transform: scale(0.98);
}

.button-primary {
    background-color: var(--color-primary);
    color: var(--color-text-light);
}

.button-secondary {
    background-color: var(--color-bg-light);
    color: var(--color-text-light);
    border: 1px solid var(--color-primary);
}

.button-danger {
    background-color: var(--color-danger);
    color: var(--color-text-light);
}

.button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.icon-button, .avatar-container {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
}

.icon-button svg {
    width: 24px;
    height: 24px;
    color: var(--color-accent);
}

.profile-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid var(--color-primary);
    cursor: pointer;
}

.view-content {
    padding: 0 var(--spacing-md);
}

.view-content section {
    padding-bottom: var(--spacing-lg);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    margin-bottom: var(--spacing-lg);
}

.view-content section:last-of-type {
    border-bottom: none;
    margin-bottom: 0;
}

.view-content h3, .view-content h4 {
    margin-top: 0;
}

.form-view {
    padding-top: var(--spacing-md);
    padding-bottom: 100px; /* Provides a safe buffer for the sticky footer */
}

.form-group {
    margin-bottom: var(--spacing-md);
}

.form-group label {
    display: block;
    margin-bottom: var(--spacing-xs);
    color: var(--color-text-muted);
    font-size: 0.9em;
}

.input-field {
    width: 100%;
    padding: var(--spacing-sm);
    font-size: 1em;
    border-radius: var(--border-radius);
    border: 1px solid var(--color-bg-light);
    background-color: var(--color-bg-light);
    color: var(--color-text-light);
    outline: none;
}

.input-field.auto-expand {
    resize: none;
    min-height: 80px;
}

.card {
    background-color: var(--color-bg-light);
    border-radius: var(--border-radius);
    padding: var(--spacing-md);
    box-shadow: var(--shadow-sm);
    transition: transform 0.1s ease;
    cursor: pointer;
}

.card:active {
    transform: scale(0.98);
}

.list-cards {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.empty-state {
    text-align: center;
    color: var(--color-text-muted);
    font-style: italic;
    padding: var(--spacing-md);
}

/* Lock View */
.lock-screen-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    width: 100%;
    max-width: 360px;
    margin: auto;
}

.lock-logo {
    width: 80px;
    height: 80px;
    opacity: 0.8;
}

.lock-title {
    font-size: 2.5em;
    font-weight: 700;
    color: var(--color-primary);
    margin: var(--spacing-sm) 0 var(--spacing-xs);
    text-shadow: 0 0 10px var(--color-primary);
}

.lock-subtitle {
    font-size: 1em;
    color: var(--color-text-muted);
    margin: 0;
}

.pin-display-container {
    margin-top: var(--spacing-lg);
    width: 100%;
    display: flex;
    justify-content: center;
}

.pin-input {
    width: 100%;
    max-width: 200px;
    text-align: center;
    font-size: 2.5em;
    color: var(--color-text-light);
    background: transparent;
    border: none;
    border-bottom: 2px solid var(--color-primary);
    outline: none;
    caret-color: transparent;
    -webkit-text-security: disc;
    padding: var(--spacing-xs);
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--spacing-md);
  margin-top: var(--spacing-lg);
  width: 100%;
  max-width: 300px;
}

/* If your HTML has <div class="keypad-row"> wrappers, flatten them so the
   buttons themselves become the grid items. Safe even if no wrappers exist. */
.keypad-row { display: contents; }

.keypad-btn {
  width: 100%;
  height: 60px;
  font-size: 1.5em;
  font-weight: bold;
  color: var(--color-text-light);
  background-color: var(--color-bg-light);
  border: none;
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: transform 0.1s ease;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
}

.keypad-btn:active { transform: scale(0.95); }

.keypad-spacer { visibility: hidden; }

/* ✓ stays styled but no longer spans full width */
.keypad-btn[data-key="enter"] {
  /* remove: grid-column: 1 / -1; */
  background-color: var(--color-accent);
  color: var(--color-bg-dark);
  font-weight: 700;
}

/* Dashboard View */
.dashboard-stats {
    display: flex;
    justify-content: space-between;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.stat-card {
    flex: 1;
    background-color: var(--color-bg-light);
    border-radius: var(--border-radius);
    padding: var(--spacing-md);
    text-align: center;
    box-shadow: var(--shadow-sm);
}

.stat-card h4 {
    margin: 0 0 var(--spacing-xs) 0;
    color: var(--color-text-muted);
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-number {
    margin: 0;
    font-size: 2.5em;
    font-weight: 700;
    color: var(--color-primary);
}

.dashboard-quick-links h3 {
    margin-top: 0;
    margin-bottom: var(--spacing-md);
}

.quick-links-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--spacing-md);
}

.button-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: var(--color-bg-light);
    border-radius: var(--border-radius);
    padding: var(--spacing-md);
    text-align: center;
    text-decoration: none;
    color: var(--color-text-light);
    border: none;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s, box-shadow 0.2s;
}

.button-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.button-card svg {
    width: 48px;
    height: 48px;
    color: var(--color-primary);
    margin-bottom: var(--spacing-sm);
}

.button-card span {
    font-weight: 600;
}

/* Image Preview Styling */
.image-preview-container {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-sm);
}

.image-preview-item {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    border-radius: var(--border-radius-sm);
    background-size: cover;
    background-position: center;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.image-preview-item .remove-image-btn {
    position: absolute;
    top: var(--spacing-sm);
    right: var(--spacing-sm);
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.image-preview-item .remove-image-btn:hover {
    background-color: var(--color-danger);
}