/* ═══════════════════════════════════════════
   PURPLETEC PWA — Corporate Design
   ═══════════════════════════════════════════ */

:root {
  --purple: #AA73C8;
  --purple-light: #C490DE;
  --beige: #C4A882;
  --beige-hover: #B89B76;
  --dark-1: #1E2230;
  --dark-2: #232733;
  --dark-3: #292D39;
  --dark-4: #2B2F3A;
  --bg-white: #FFFFFF;
  --bg-light: #F7F7F7;
  --footer: #D0C5BC;
  --text-dark: #1E2230;
  --text-grey: #666666;
  --text-light-grey: #999999;
  --danger: #E74C3C;
  --danger-hover: #C0392B;
  --success: #27AE60;
  --nav-height: 64px;
  --header-height: 56px;
}

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

html, body {
  font-family: 'Poppins', sans-serif;
  background: var(--bg-light);
  color: var(--text-dark);
  height: 100%;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ─── Header ─── */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--dark-1);
  z-index: 100;
  display: flex;
  align-items: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.header-content {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
}

.header-logo {
  width: 32px;
  height: 32px;
  border-radius: 6px;
}

.header-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--bg-white);
  letter-spacing: 0.5px;
}

/* ─── Main Content ─── */
#app-content {
  position: fixed;
  top: var(--header-height);
  bottom: var(--nav-height);
  left: 0;
  right: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  background: var(--bg-light);
}

/* ─── Bottom Navigation ─── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: var(--dark-1);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 100;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.2);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px 16px;
  color: var(--text-light-grey);
  transition: color 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.nav-item.active {
  color: var(--purple);
}

.nav-item:active {
  transform: scale(0.95);
}

.nav-icon {
  width: 24px;
  height: 24px;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.3px;
}

/* ─── Search Bar ─── */
.search-container {
  padding: 12px 16px;
  background: var(--bg-white);
  border-bottom: 1px solid #E8E8E8;
  position: sticky;
  top: 0;
  z-index: 10;
}

.search-input {
  width: 100%;
  padding: 10px 16px 10px 40px;
  border: 1px solid #E0E0E0;
  border-radius: 10px;
  font-family: 'Poppins', sans-serif;
  font-size: 14px;
  background: var(--bg-light);
  color: var(--text-dark);
  outline: none;
  transition: border-color 0.2s;
}

.search-input:focus {
  border-color: var(--purple);
}

.search-wrapper {
  position: relative;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-light-grey);
}

/* ─── Floating Action Button ─── */
.fab {
  position: fixed;
  bottom: calc(var(--nav-height) + 16px);
  right: 16px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--beige);
  color: var(--bg-white);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(196, 168, 130, 0.4);
  transition: background 0.2s, transform 0.15s;
  z-index: 50;
  -webkit-tap-highlight-color: transparent;
}

.fab:hover {
  background: var(--beige-hover);
}

.fab:active {
  transform: scale(0.92);
}

.fab svg {
  width: 28px;
  height: 28px;
  stroke: white;
  stroke-width: 2.5;
}

/* ─── Customer Cards ─── */
.customer-list {
  padding: 8px 16px 80px;
}

.customer-card {
  background: var(--bg-white);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  border-left: 3px solid var(--purple);
  -webkit-tap-highlight-color: transparent;
}

.customer-card:active {
  transform: scale(0.98);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.customer-card .company-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-dark);
  margin-bottom: 4px;
}

.customer-card .contact-person {
  font-size: 13px;
  color: var(--text-grey);
  margin-bottom: 2px;
}

.customer-card .contact-info {
  font-size: 12px;
  color: var(--text-light-grey);
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.customer-card .city-tag {
  display: inline-block;
  background: var(--bg-light);
  color: var(--text-grey);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  margin-top: 6px;
}

/* ─── Empty State ─── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-light-grey);
  text-align: center;
}

.empty-state svg {
  width: 64px;
  height: 64px;
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty-state h3 {
  font-size: 16px;
  font-weight: 500;
  margin-bottom: 8px;
  color: var(--text-grey);
}

.empty-state p {
  font-size: 13px;
}

/* ─── Forms ─── */
.form-view {
  padding: 16px;
  padding-bottom: 100px;
}

.form-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.back-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-white);
  border: 1px solid #E0E0E0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.back-btn:active {
  background: var(--bg-light);
}

.back-btn svg {
  width: 20px;
  height: 20px;
  color: var(--text-dark);
}

.form-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-dark);
}

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

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--purple);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-input,
.form-textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #E0E0E0;
  border-radius: 8px;
  font-family: 'Poppins', sans-serif;
  font-size: 14px;
  color: var(--text-dark);
  background: var(--bg-white);
  outline: none;
  transition: border-color 0.2s;
}

.form-input:focus,
.form-textarea:focus {
  border-color: var(--purple);
}

.form-textarea {
  min-height: 100px;
  resize: vertical;
}

.form-row {
  display: flex;
  gap: 10px;
}

.form-row .form-group {
  flex: 1;
}

.form-row .form-group.small {
  flex: 0 0 100px;
}

.form-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dark);
  margin: 24px 0 12px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--bg-light);
}

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-family: 'Poppins', sans-serif;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
  -webkit-tap-highlight-color: transparent;
}

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

.btn-primary {
  background: var(--beige);
  color: var(--bg-white);
  width: 100%;
}

.btn-primary:hover {
  background: var(--beige-hover);
}

.btn-danger {
  background: var(--danger);
  color: var(--bg-white);
  width: 100%;
}

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

.btn-outline {
  background: transparent;
  color: var(--text-grey);
  border: 1px solid #E0E0E0;
}

.btn-outline:hover {
  background: var(--bg-light);
}

.btn-small {
  padding: 8px 16px;
  font-size: 12px;
}

.btn-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 24px;
}

/* ─── Detail View ─── */
.detail-view {
  padding: 16px;
  padding-bottom: 100px;
}

.detail-section {
  background: var(--bg-white);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.detail-section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--purple);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 8px 0;
  border-bottom: 1px solid var(--bg-light);
}

.detail-row:last-child {
  border-bottom: none;
}

.detail-label {
  font-size: 12px;
  color: var(--text-light-grey);
  flex-shrink: 0;
  width: 110px;
}

.detail-value {
  font-size: 14px;
  color: var(--text-dark);
  text-align: right;
  flex: 1;
  word-break: break-word;
}

.detail-value a {
  color: var(--purple);
  text-decoration: none;
}

.detail-value.notes {
  text-align: left;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
}

/* ─── Documents ─── */
.doc-list {
  list-style: none;
}

.doc-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--bg-light);
}

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

.doc-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.doc-icon {
  width: 32px;
  height: 32px;
  background: #FFF0F0;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--danger);
  font-size: 12px;
  font-weight: 700;
}

.doc-text {
  min-width: 0;
  flex: 1;
  overflow: hidden;
}

.doc-name {
  font-size: 13px;
  color: var(--text-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.doc-size {
  font-size: 11px;
  color: var(--text-light-grey);
}

.doc-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  margin-left: 8px;
}

.doc-action-btn {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.doc-action-btn.rename {
  background: var(--bg-light);
  color: var(--beige-hover);
}

.doc-action-btn.download {
  background: var(--bg-light);
  color: var(--purple);
}

.doc-action-btn.delete {
  background: #FFF0F0;
  color: var(--danger);
}

.doc-action-btn svg {
  width: 16px;
  height: 16px;
}

/* ─── Document Navigation Buttons ─── */
.doc-nav-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.doc-nav-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px;
  background: var(--bg-light);
  border: 1px solid #E8E8E8;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  font-family: 'Poppins', sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.doc-nav-btn:active {
  background: #EEEEEE;
  border-color: var(--purple);
}

.doc-nav-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(170, 115, 200, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.doc-nav-icon svg {
  width: 20px;
  height: 20px;
  color: var(--purple);
}

.doc-nav-text {
  flex: 1;
  text-align: left;
}

.doc-nav-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dark);
}

.doc-nav-count {
  display: block;
  font-size: 12px;
  color: var(--text-light-grey);
  margin-top: 2px;
}

.doc-nav-arrow {
  width: 18px;
  height: 18px;
  color: var(--text-light-grey);
  flex-shrink: 0;
}

/* ─── Docs Customer Info ─── */
.docs-customer-info {
  font-size: 13px;
  color: var(--text-light-grey);
  margin-bottom: 12px;
  padding-left: 4px;
}

.docs-empty {
  padding: 20px 0;
  text-align: center;
  color: var(--text-light-grey);
  font-size: 13px;
}

/* ─── Upload Area ─── */
.upload-area {
  border: 2px dashed #D0D0D0;
  border-radius: 10px;
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  margin-top: 12px;
  -webkit-tap-highlight-color: transparent;
}

.upload-area:active,
.upload-area.dragover {
  border-color: var(--purple);
  background: rgba(170, 115, 200, 0.05);
}

.upload-area svg {
  width: 36px;
  height: 36px;
  color: var(--text-light-grey);
  margin-bottom: 8px;
}

.upload-area p {
  font-size: 13px;
  color: var(--text-grey);
}

.upload-area .upload-hint {
  font-size: 11px;
  color: var(--text-light-grey);
  margin-top: 4px;
}

/* ─── Placeholder Views ─── */
.placeholder-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 40px;
  text-align: center;
  color: var(--text-light-grey);
}

.placeholder-view svg {
  width: 80px;
  height: 80px;
  margin-bottom: 20px;
  opacity: 0.3;
}

.placeholder-view h2 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-grey);
  margin-bottom: 8px;
}

.placeholder-view p {
  font-size: 14px;
}

/* ─── Toast Notification ─── */
.toast {
  position: fixed;
  bottom: calc(var(--nav-height) + 20px);
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--dark-1);
  color: var(--bg-white);
  padding: 12px 24px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  z-index: 200;
  opacity: 0;
  transition: transform 0.3s, opacity 0.3s;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ─── Confirm Dialog ─── */
.dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.dialog-overlay.show {
  opacity: 1;
  pointer-events: all;
}

.dialog-box {
  background: var(--bg-white);
  border-radius: 14px;
  padding: 24px;
  max-width: 320px;
  width: 100%;
  text-align: center;
  transform: scale(0.9);
  transition: transform 0.2s;
}

.dialog-overlay.show .dialog-box {
  transform: scale(1);
}

.dialog-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
}

.dialog-message {
  font-size: 13px;
  color: var(--text-grey);
  margin-bottom: 20px;
  line-height: 1.5;
}

.dialog-buttons {
  display: flex;
  gap: 10px;
}

.dialog-buttons .btn {
  flex: 1;
  padding: 10px;
}

/* ─── Loading Spinner ─── */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255,255,255,0.3);
  border-radius: 50%;
  border-top-color: white;
  animation: spin 0.6s linear infinite;
}

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

/* ─── Responsive ─── */
@media (min-width: 600px) {
  #app-content {
    max-width: 480px;
    margin: 0 auto;
    left: auto;
    right: auto;
  }
  
  .bottom-nav {
    max-width: 480px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 16px 16px 0 0;
  }
  
  .app-header {
    max-width: 480px;
    left: 50%;
    transform: translateX(-50%);
  }
  
  .fab {
    right: calc(50% - 224px);
  }
}
