/* ============================================================
   iPadOS Design System for Mailer
   Inspired by Apple iPadOS 17 / 18 Human Interface Guidelines
   ============================================================ */

:root {
  --ios-bg: #F2F2F7;
  --ios-card-bg: #FFFFFF;
  --ios-sidebar-bg: rgba(255, 255, 255, 0.78);
  --ios-sidebar-dark: rgba(28, 28, 30, 0.85);
  --ios-text-primary: #1C1C1E;
  --ios-text-secondary: #8E8E93;
  --ios-text-tertiary: #C7C7CC;
  
  /* Apple System Colors */
  --ios-blue: #007AFF;
  --ios-blue-rgb: 0, 122, 255;
  --ios-indigo: #5856D6;
  --ios-purple: #AF52DE;
  --ios-pink: #FF2D55;
  --ios-green: #34C759;
  --ios-green-rgb: 52, 199, 89;
  --ios-orange: #FF9500;
  --ios-red: #FF3B30;
  --ios-teal: #30B0C7;
  --ios-gray-light: #E5E5EA;
  
  /* Surfaces & Borders */
  --ios-border: rgba(60, 60, 67, 0.09);
  --ios-border-subtle: rgba(60, 60, 67, 0.05);
  --ios-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.03);
  --ios-shadow-md: 0 8px 24px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.02);
  --ios-shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.08);
  --ios-radius-xs: 8px;
  --ios-radius-sm: 12px;
  --ios-radius-md: 18px;
  --ios-radius-lg: 24px;
  --ios-radius-pill: 9999px;
  
  --font-family-apple: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
}

body {
  font-family: var(--font-family-apple);
  background-color: var(--ios-bg);
  background-image: 
    radial-gradient(at 10% 10%, rgba(0, 122, 255, 0.04) 0px, transparent 50%),
    radial-gradient(at 90% 90%, rgba(88, 86, 214, 0.04) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--ios-text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  margin: 0;
  padding: 0;
}

/* ── Floating iPadOS Sidebar ─────────────────────────────── */
.ipados-app-wrapper {
  display: flex;
  min-height: 100vh;
  padding: 16px;
  gap: 16px;
  box-sizing: border-box;
}

.ipados-sidebar {
  width: 250px;
  min-width: 250px;
  background: var(--ios-sidebar-bg);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: var(--ios-radius-lg);
  box-shadow: var(--ios-shadow-md);
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 16px;
  z-index: 100;
  box-sizing: border-box;
  overflow: hidden;
  align-self: flex-start;
}

.ipados-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 6px 10px 6px;
  border-bottom: 1px solid var(--ios-border-subtle);
  margin-bottom: 8px;
}

.ipados-app-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #007AFF 0%, #5856D6 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 19px;
  box-shadow: 0 4px 12px rgba(0, 122, 255, 0.35);
  flex-shrink: 0;
}

.ipados-brand-text h1 {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.02em;
  color: var(--ios-text-primary);
  line-height: 1.15;
}

.ipados-brand-text span {
  font-size: 0.72rem;
  color: var(--ios-text-secondary);
  font-weight: 500;
}

.ipados-nav {
  list-style: none;
  padding: 0;
  margin: 0;
  overflow: hidden;
}

.ipados-nav-item {
  margin-bottom: 2px;
}

.ipados-nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 11px;
  border-radius: 10px;
  color: var(--ios-text-primary);
  text-decoration: none;
  font-size: 0.86rem;
  font-weight: 500;
  transition: all 0.15s ease;
}

.ipados-nav-link:hover {
  background: rgba(0, 0, 0, 0.04);
  color: var(--ios-text-primary);
}

.ipados-nav-link.active {
  background: var(--ios-blue);
  color: #FFFFFF;
  box-shadow: 0 4px 14px rgba(var(--ios-blue-rgb), 0.35);
}

.ipados-nav-link .nav-icon {
  font-size: 1.05rem;
  width: 20px;
  text-align: center;
  display: inline-block;
}

.ipados-sidebar-footer {
  padding-top: 8px;
  margin-top: 8px;
  border-top: 1px solid var(--ios-border-subtle);
}

.ipados-user-badge {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: rgba(0, 0, 0, 0.03);
  border-radius: 10px;
}
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.03);
  border-radius: var(--ios-radius-sm);
}

.ipados-user-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ipados-user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #34C759;
  color: #fff;
  font-weight: 600;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Main Content Area ────────────────────────────────────── */
.ipados-main-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.ipados-topbar {
  background: var(--ios-sidebar-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: var(--ios-radius-md);
  padding: 12px 20px;
  margin-bottom: 16px;
  box-shadow: var(--ios-shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ipados-topbar-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--ios-text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.ipados-system-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 500;
  color: #248A3D;
  background: rgba(52, 199, 89, 0.12);
  padding: 4px 10px;
  border-radius: var(--ios-radius-pill);
}

.ipados-system-status .pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #34C759;
  box-shadow: 0 0 6px rgba(52, 199, 89, 0.6);
}

/* ── iPadOS Cards & Widgets ───────────────────────────────── */
.card, .ipados-card {
  background: var(--ios-card-bg);
  border: 1px solid var(--ios-border);
  border-radius: var(--ios-radius-md);
  box-shadow: var(--ios-shadow-md);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  overflow: hidden;
}

.card:hover, .ipados-card:hover {
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.07);
}

.card-header {
  background: transparent;
  border-bottom: 1px solid var(--ios-border-subtle);
  padding: 16px 20px;
  font-weight: 600;
  font-size: 1rem;
}

.card-body {
  padding: 20px;
}

/* Widget Cards for Dashboard & Stats (Ultra Compact iPadOS Style) */
.ipados-widget {
  background: #FFFFFF;
  border: 1px solid var(--ios-border);
  border-radius: 12px;
  padding: 8px 10px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  overflow: hidden;
}

.ipados-widget:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.ipados-widget-icon {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  flex-shrink: 0;
}

.ipados-widget-icon.blue   { background: rgba(0, 122, 255, 0.12); color: #007AFF; }
.ipados-widget-icon.indigo { background: rgba(88, 86, 214, 0.12); color: #5856D6; }
.ipados-widget-icon.green  { background: rgba(52, 199, 89, 0.12); color: #34C759; }
.ipados-widget-icon.orange { background: rgba(255, 149, 0, 0.12); color: #FF9500; }
.ipados-widget-icon.red    { background: rgba(255, 59, 48, 0.12); color: #FF3B30; }
.ipados-widget-icon.teal   { background: rgba(48, 176, 199, 0.12); color: #30B0C7; }

.ipados-widget-val {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ios-text-primary);
  line-height: 1.15;
  margin: 0;
  white-space: nowrap;
}

.ipados-widget-lbl {
  font-size: 0.64rem;
  color: var(--ios-text-secondary);
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0.01em;
  line-height: 1.2;
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── iPadOS Tables ────────────────────────────────────────── */
.table-responsive {
  border-radius: var(--ios-radius-md);
  background: #FFFFFF;
  border: 1px solid var(--ios-border);
  box-shadow: var(--ios-shadow-sm);
  overflow: hidden;
}

.table {
  margin-bottom: 0;
  font-size: 0.92rem;
  border-collapse: separate;
  border-spacing: 0;
}

.table th {
  background: #FAFAFC;
  color: var(--ios-text-secondary);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 12px 16px;
  border-bottom: 1px solid var(--ios-border);
  white-space: nowrap;
}

.table td {
  padding: 14px 16px;
  vertical-align: middle;
  border-bottom: 1px solid var(--ios-border-subtle);
  color: var(--ios-text-primary);
}

.table tr:last-child td {
  border-bottom: none;
}

.table-hover tbody tr:hover {
  background-color: rgba(0, 122, 255, 0.025);
}

/* ── Buttons (Pill & Rounded) ────────────────────────────── */
.btn {
  font-family: var(--font-family-apple);
  font-weight: 500;
  font-size: 0.88rem;
  padding: 8px 16px;
  border-radius: var(--ios-radius-sm);
  transition: all 0.15s ease;
  border: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
}

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

.btn-primary {
  background: var(--ios-blue);
  color: #FFFFFF;
  box-shadow: 0 2px 8px rgba(var(--ios-blue-rgb), 0.25);
}

.btn-primary:hover {
  background: #0066D6;
  color: #FFFFFF;
  box-shadow: 0 4px 14px rgba(var(--ios-blue-rgb), 0.35);
  transform: translateY(-1px);
}

.btn-secondary {
  background: #E5E5EA;
  color: #1C1C1E;
}

.btn-secondary:hover {
  background: #D1D1D6;
  color: #1C1C1E;
}

.btn-success {
  background: #34C759;
  color: #FFFFFF;
  box-shadow: 0 2px 8px rgba(var(--ios-green-rgb), 0.25);
}
.btn-success:hover { background: #2EB14F; color: #FFFFFF; }

.btn-danger {
  background: #FF3B30;
  color: #FFFFFF;
}
.btn-danger:hover { background: #E0352B; color: #FFFFFF; }

.btn-warning {
  background: #FF9500;
  color: #FFFFFF;
}

.btn-info {
  background: #5856D6;
  color: #FFFFFF;
}

.btn-outline-secondary {
  border: 1px solid rgba(60, 60, 67, 0.18);
  background: rgba(255, 255, 255, 0.6);
  color: var(--ios-text-primary);
}

.btn-outline-secondary:hover {
  background: #FFFFFF;
  color: var(--ios-text-primary);
  border-color: rgba(60, 60, 67, 0.3);
}

.btn-pill {
  border-radius: var(--ios-radius-pill);
}

.btn-xs {
  padding: 4px 10px;
  font-size: 0.78rem;
  border-radius: 8px;
}

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  font-weight: 500;
  font-size: 0.68rem;
  padding: 2px 7px;
  border-radius: var(--ios-radius-pill);
  letter-spacing: 0.01em;
  line-height: 1.25;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  vertical-align: middle;
  box-shadow: none;
}

.badge.bg-primary {
  background: rgba(0, 122, 255, 0.12) !important;
  color: #007AFF !important;
}

.badge.bg-success {
  background: rgba(52, 199, 89, 0.15) !important;
  color: #248A3D !important;
}

.badge.bg-warning {
  background: rgba(255, 149, 0, 0.15) !important;
  color: #C97200 !important;
}

.badge.bg-danger {
  background: rgba(255, 59, 48, 0.15) !important;
  color: #D70015 !important;
}

.badge.bg-secondary {
  background: rgba(142, 142, 147, 0.13) !important;
  color: #636366 !important;
}

.badge.bg-info {
  background: rgba(88, 86, 214, 0.15) !important;
  color: #5856D6 !important;
}

.badge-xs {
  font-size: 0.62rem;
  padding: 1px 5px;
}

/* ── Inputs & Controls ───────────────────────────────────── */
.form-control, .form-select {
  border-radius: var(--ios-radius-sm);
  border: 1px solid var(--ios-border);
  background: #FFFFFF;
  padding: 9px 14px;
  font-size: 0.92rem;
  color: var(--ios-text-primary);
  transition: all 0.2s ease;
}

.form-control:focus, .form-select:focus {
  border-color: var(--ios-blue);
  box-shadow: 0 0 0 3px rgba(var(--ios-blue-rgb), 0.18);
  outline: none;
}

.form-label {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--ios-text-primary);
  margin-bottom: 6px;
}

/* iOS Toggle Switch */
.form-check-input:checked {
  background-color: #34C759;
  border-color: #34C759;
}

.form-switch .form-check-input {
  width: 2.4em;
  height: 1.3em;
  border-radius: 2em;
  cursor: pointer;
  transition: background-position .15s ease-in-out, background-color .15s ease-in-out;
}

/* ── Alerts ──────────────────────────────────────────────── */
.alert {
  border-radius: var(--ios-radius-md);
  border: 1px solid transparent;
  padding: 14px 18px;
  font-size: 0.92rem;
  box-shadow: var(--ios-shadow-sm);
}

.alert-success {
  background: rgba(52, 199, 89, 0.12);
  color: #1E7031;
  border-color: rgba(52, 199, 89, 0.25);
}

.alert-danger {
  background: rgba(255, 59, 48, 0.12);
  color: #B21B1B;
  border-color: rgba(255, 59, 48, 0.25);
}

.alert-warning {
  background: rgba(255, 149, 0, 0.12);
  color: #9E5800;
  border-color: rgba(255, 149, 0, 0.25);
}

.alert-info {
  background: rgba(0, 122, 255, 0.12);
  color: #0056B3;
  border-color: rgba(0, 122, 255, 0.25);
}

/* ── Pagination ──────────────────────────────────────────── */
.pagination {
  gap: 4px;
}

.page-item .page-link {
  border-radius: var(--ios-radius-xs) !important;
  border: 1px solid var(--ios-border);
  color: var(--ios-text-primary);
  padding: 6px 12px;
  font-size: 0.88rem;
}

.page-item.active .page-link {
  background-color: var(--ios-blue);
  border-color: var(--ios-blue);
  color: #FFFFFF;
}

/* ── Modal in iPadOS Style ────────────────────────────────── */
.modal-content {
  border-radius: var(--ios-radius-lg);
  border: 1px solid var(--ios-border);
  box-shadow: var(--ios-shadow-lg);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
}

.modal-header {
  border-bottom: 1px solid var(--ios-border-subtle);
  padding: 18px 24px;
}

.modal-footer {
  border-top: 1px solid var(--ios-border-subtle);
  padding: 14px 24px;
}

/* ── iPad Frame Preview Simulator ────────────────────────── */
.ipad-simulator-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 15px;
  background: #1C1C1E;
  border-radius: 36px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.35);
  max-width: 680px;
  margin: 0 auto;
  position: relative;
}

.ipad-camera-dot {
  position: absolute;
  top: 7px;
  left: 50%;
  transform: translateX(-50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #2C2C2E;
  box-shadow: inset 0 0 2px #000;
}

.ipad-screen-container {
  width: 100%;
  height: 600px;
  background: #FFFFFF;
  border-radius: 24px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.ipad-screen-statusbar {
  height: 24px;
  background: #FAFAFC;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  font-size: 11px;
  font-weight: 600;
  color: #1C1C1E;
  border-bottom: 1px solid #ECECEC;
}

.ipad-screen-iframe {
  flex: 1;
  width: 100%;
  border: none;
  background: #F2F2F7;
}

/* ── Segmented Control in iPadOS Style ──────────────────── */
.ipados-segmented-tabs {
  background: rgba(118, 118, 128, 0.12);
  padding: 4px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}
.ipados-segmented-tabs::-webkit-scrollbar { display: none; }

.ipados-segmented-tab {
  padding: 6px 14px;
  border-radius: 10px;
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--ios-text-primary);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: all 0.15s ease;
  border: none;
  background: transparent;
}

.ipados-segmented-tab:hover {
  color: var(--ios-blue);
}

.ipados-segmented-tab.active {
  background: #FFFFFF;
  color: var(--ios-blue);
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
}

.ipados-segmented-tab .badge {
  font-size: 0.72rem;
  padding: 2px 7px;
  border-radius: 9999px;
}

/* ── Apple Gradient Progress Bar ─────────────────────────── */
.ipados-progress-wrap {
  background: rgba(118, 118, 128, 0.12);
  border-radius: 9999px;
  padding: 3px;
  height: 22px;
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.06);
}

.ipados-progress-fill {
  height: 100%;
  border-radius: 9999px;
  background: linear-gradient(90deg, #007AFF 0%, #34C759 100%);
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 8px;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(52, 199, 89, 0.35);
}

/* ── Status Dots ─────────────────────────────────────────── */
.ipados-status-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.9), 0 2px 5px rgba(0,0,0,0.2);
  cursor: pointer;
  vertical-align: middle;
  transition: transform 0.15s ease;
}
.ipados-status-dot:hover {
  transform: scale(1.25);
}

/* ── Responsive adjustments ──────────────────────────────── */
@media (max-width: 992px) {
  .ipados-app-wrapper {
    flex-direction: column;
  }
  .ipados-sidebar {
    width: 100%;
    height: auto;
    position: static;
  }
}
