/* ========================================================
   Mobile App Styles — Dark theme like myqrcards
   ======================================================== */

/* Bottom Tab Bar */
.mobile-tabbar { display: none; }

@media (max-width: 768px) {
  /* === Dark Theme Override === */
  body {
    --bg-main: #1A1D2E;
    --surface: #242840;
    --surface-hover: #2E3352;
    --border: #363B58;
    --text-primary: #E8EAF0;
    --text-secondary: #9EA3BE;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
    background: var(--bg-main);
    color: var(--text-primary);
  }

  /* Hide desktop elements */
  .sidebar, .sidebar-overlay, .mobile-header { display: none !important; }
  .main-content { margin-left: 0 !important; padding-top: 0 !important; padding-bottom: 80px !important; }
  .main-header { background: var(--bg-main); border-bottom: 1px solid var(--border); }
  .page-title { color: var(--text-primary); }

  /* Form inputs dark */
  .form-input, .form-select, .form-textarea {
    background: var(--surface) !important;
    border-color: var(--border) !important;
    color: var(--text-primary) !important;
  }
  .form-input::placeholder, .form-textarea::placeholder { color: var(--text-secondary) !important; }
  .form-input:focus, .form-select:focus, .form-textarea:focus {
    border-color: var(--secondary) !important;
    box-shadow: 0 0 0 3px rgba(123,173,194,0.15) !important;
  }
  label { color: var(--text-secondary) !important; }

  .search-input { background: var(--surface) !important; color: var(--text-primary) !important; border-color: var(--border) !important; }

  /* Panel dark */
  .panel { background: var(--surface); box-shadow: var(--shadow-sm); }
  .panel-title { color: var(--text-primary); }

  /* Employee cards dark */
  .emp-card-mobile { background: var(--surface); }
  .emp-card-name { color: var(--text-primary); }

  /* Employee mobile cards */
  .emp-cards-mobile { display: flex; flex-direction: column; gap: 12px; }
  .emp-card-mobile {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 16px;
    position: relative;
  }
  .emp-card-top {
    display: flex;
    align-items: center;
    gap: 12px;
  }
  .emp-card-info { flex: 1; min-width: 0; }
  .emp-card-name { font-size: 16px; font-weight: 600; color: #E8EAF0 !important; }
  .emp-card-position { font-size: 13px; color: #9EA3BE; margin-top: 2px; }
  .emp-card-dept { font-size: 12px; color: #7BADC2; margin-top: 2px; font-style: italic; }
  .emp-card-bottom { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
  .emp-card-email { font-size: 13px; color: #9EA3BE; }
  .emp-card-mobile .avatar img {
    width: 100%; height: 100%; object-fit: cover; border-radius: 50%;
  }

  /* Modal dark */
  .modal-dialog { background: #242840 !important; }
  .modal-header { border-color: rgba(255,255,255,0.08) !important; }
  .modal-header h3 { color: #E8EAF0 !important; }
  .modal-body { color: #E8EAF0 !important; }
  .modal-footer { background: #1E2236 !important; border-color: rgba(255,255,255,0.08) !important; }
  .modal-close { background: #363B58 !important; color: #9EA3BE !important; }
  .modal-close:hover { background: #4A5073 !important; color: #fff !important; }
  .modal-btn-cancel { background: #363B58 !important; color: #E8EAF0 !important; }
  .modal-btn-cancel:hover { background: #4A5073 !important; }
  .modal-backdrop { backdrop-filter: blur(8px); }

  /* === Bottom Tab Bar === */
  .mobile-tabbar {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 64px;
    background: #15172A;
    border-top: 1px solid rgba(255,255,255,0.08);
    z-index: 999;
    align-items: flex-end;
    justify-content: space-around;
    padding: 0 4px;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .tabbar-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 8px 0 6px;
    background: none;
    border: none;
    color: #6B7094;
    font-size: 10px;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.2s;
    flex: 1;
    -webkit-tap-highlight-color: transparent;
  }

  .tabbar-item.active { color: #E8553D; }
  .tabbar-item.active svg { stroke: #E8553D; }

  .tabbar-item span { margin-top: 2px; }

  /* Center QR button */
  .tabbar-center { position: relative; }
  .tabbar-center-btn {
    width: 52px; height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, #E8553D, #FF7A5C);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: -20px;
    box-shadow: 0 4px 16px rgba(232,85,61,0.4);
    transition: transform 0.2s;
  }
  .tabbar-center:active .tabbar-center-btn { transform: scale(0.92); }
  .tabbar-center span { color: #9EA3BE; }

  /* === Mobile Dashboard === */
  .mdash { padding: 16px; }

  .mdash-card {
    position: relative;
    margin-bottom: 36px;
  }

  .mdash-face {
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    transition: opacity 0.4s ease, transform 0.5s ease;
  }

  .mdash-front {
    background: linear-gradient(135deg, #242840 0%, #1E2236 100%);
    position: relative;
    z-index: 2;
  }

  .mdash-back {
    background: #fff;
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 1;
    opacity: 0;
    transform: scale(0.95);
    pointer-events: none;
  }

  .mdash-card.flipped .mdash-front { opacity: 0; transform: scale(0.95); pointer-events: none; }
  .mdash-card.flipped .mdash-back { opacity: 1; transform: scale(1); z-index: 3; pointer-events: auto; }

  .mdash-card-inner {
    display: flex;
    padding: 24px 20px 32px;
    gap: 16px;
    min-height: 180px;
  }

  .mdash-card-left {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
  }

  .mdash-name {
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    line-height: 1.2;
    margin-bottom: 6px;
  }

  .mdash-position {
    font-size: 13px;
    color: #9EA3BE;
    margin-bottom: 2px;
  }

  .mdash-company {
    font-size: 12px;
    color: #7BADC2;
    margin-bottom: 10px;
  }

  .mdash-contact {
    font-size: 12px;
    color: #C0C4D8;
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .mdash-card-right {
    flex-shrink: 0;
    display: flex;
    align-items: center;
  }

  .mdash-photo {
    width: 120px;
    height: 140px;
    object-fit: cover;
    border-radius: 12px;
  }

  .mdash-photo-placeholder {
    width: 100px;
    height: 120px;
    border-radius: 12px;
    background: linear-gradient(135deg, #2B3E6F, #7BADC2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    font-weight: 700;
    color: #fff;
  }

  .mdash-qr-floating {
    position: absolute;
    bottom: -24px;
    left: 50%;
    transform: translateX(-50%);
    width: 48px; height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #E8553D, #FF7A5C);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(232,85,61,0.4);
    cursor: pointer;
    z-index: 10;
    transition: transform 0.3s;
  }
  .mdash-qr-floating:active { transform: translateX(-50%) scale(0.9); }

  /* Action Tiles */
  .mdash-tiles {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 8px;
  }

  .mdash-tile {
    background: var(--surface);
    border-radius: 14px;
    padding: 18px 10px 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    text-align: center;
    -webkit-tap-highlight-color: transparent;
  }

  .mdash-tile:active { transform: scale(0.96); box-shadow: 0 2px 12px rgba(0,0,0,0.3); }

  .mdash-tile svg { color: #E8553D; stroke: #E8553D; }

  .mdash-tile span {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
  }

  /* Stat cards dark */
  .stat-card { background: var(--surface); }
  .stat-value { color: var(--text-primary); }

  /* Charts */
  .chart-container { background: var(--surface); }

  /* File upload dark */
  .file-upload { background: var(--surface); border-color: var(--border); }
  .file-upload:hover, .file-upload.dragover { border-color: var(--secondary); background: rgba(123,173,194,0.08); }

  /* Data table dark */
  .data-table { background: var(--surface); }
  .data-table th { background: var(--surface-hover); color: var(--text-secondary); }
  .data-table td { color: var(--text-primary); border-color: var(--border); }
  .data-table tr:hover { background: var(--surface-hover); }

  /* Buttons */
  .btn-secondary { background: var(--surface-hover) !important; color: var(--text-primary) !important; border-color: var(--border) !important; }

  /* Editor actions dark */
  .add-field-btn { border-color: var(--border); color: var(--text-secondary); }
  .add-field-btn:hover { border-color: var(--secondary); }

  /* Field card dark */
  .field-card { background: var(--surface); border-color: var(--border); }

  /* Row actions menu dark */
  .row-actions-menu { background: var(--surface) !important; border-color: var(--border) !important; box-shadow: var(--shadow-md) !important; }
  .row-actions-menu-item { color: var(--text-primary) !important; }
  .row-actions-menu-item:hover { background: var(--surface-hover) !important; }

  /* Color picker */
  .color-picker-group input[type="color"] { border-color: var(--border); }

  /* Toast dark */
  .toast { background: var(--surface) !important; color: var(--text-primary) !important; box-shadow: var(--shadow-md) !important; }

  /* Search box dark */
  .search-box { background: var(--surface); border-color: var(--border); }

  /* All employees button */
  .mdash-all-btn {
    display: block;
    width: 100%;
    margin-top: 16px;
    padding: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    transition: background 0.2s;
    -webkit-tap-highlight-color: transparent;
  }
  .mdash-all-btn:active { background: var(--surface-hover); }

  /* Empty state dark */
  .empty-state-text { color: var(--text-secondary); }
  .empty-state-icon { color: var(--text-secondary); }

  /* Analytics mobile */
  .stats-grid { grid-template-columns: 1fr 1fr !important; gap: 10px !important; }
  .stat-card { padding: 14px !important; gap: 10px !important; }
  .stat-value { font-size: 22px !important; }
  .stat-label { font-size: 11px !important; }
  .stat-icon { width: 40px !important; height: 40px !important; font-size: 18px !important; }
  .chart-container { padding: 16px !important; }

  .analytics-top-list { display: flex; flex-direction: column; gap: 8px; }
  .analytics-top-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    background: var(--surface-hover);
    border-radius: 10px;
  }
  .analytics-top-name { font-size: 14px; font-weight: 600; color: var(--text-primary); }
  .analytics-top-pos { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
  .analytics-top-views {
    font-size: 18px; font-weight: 700; color: #E8553D;
    white-space: nowrap;
  }
  .analytics-top-views small { font-size: 11px; font-weight: 400; color: var(--text-secondary); }

  /* Badge dark */
  .badge { background: var(--surface-hover) !important; color: var(--text-primary) !important; }
}
