/* ── Manage Share Access ───────────────────────────────── */
@keyframes msFadeUp {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes spin { to { transform: rotate(360deg); } }

body {
    font-family: var(--font-family);
    background: #f1f5f9;
    min-height: 100vh;
    color: var(--text-primary);
    margin: 0; padding: 0; line-height: 1.6;
}

/* ── Hero ── */

/* ── Hero right-side controls ── */

/* ── Lang switcher ── */
.lang-switcher {
    display: flex; align-items: center; gap: 4px;
    padding: 4px 6px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 8px;
}
.lang-btn {
    padding: 5px 11px;
    border: 1px solid rgba(255,255,255,0.15); border-radius: 6px;
    font-size: 12px; font-weight: 700; cursor: pointer;
    background: transparent; color: #94a3b8;
    font-family: var(--font-family);
    transition: background 0.15s, color 0.15s;
}
.lang-btn:hover { background: rgba(255,255,255,0.1); color: #fff; }
.lang-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── Hero CTA button ── */
.ms-hero-action .btn-primary {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 10px 18px;
    background: var(--primary); color: #fff;
    border: none; border-radius: 9px;
    font-size: 13px; font-weight: 700; cursor: pointer;
    font-family: var(--font-family);
    transition: background 0.15s, transform 0.15s;
    white-space: nowrap;
}
.ms-hero-action .btn-primary:hover { background: var(--primary-dark, #4f46e5); transform: translateY(-1px); }

/* ── Page container ── */
.ms-page {
    max-width: 1100px; margin: 0 auto;
    padding: 28px 24px 48px;
    animation: msFadeUp 0.35s ease;
}
#alertContainer { margin-bottom: 16px; }
#alertContainer:empty { display: none; }

/* ── Alerts ── */
.alert {
    padding: 14px 18px; border-radius: 10px;
    font-size: 13.5px; font-weight: 500;
    border: 1px solid; margin-bottom: 8px;
}
.alert-success { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
.alert-error   { background: #fef2f2; color: #b91c1c; border-color: #fca5a5; }
.alert-info    { background: #eef2ff; color: #3730a3; border-color: #c7d2fe; }

/* ── White card ── */
.ms-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px; padding: 22px 24px;
    box-shadow: var(--shadow-sm); margin-bottom: 16px;
}
.ms-card-title {
    font-size: 14px; font-weight: 800; color: var(--text-primary);
    margin: 0 0 14px; display: flex; align-items: center; gap: 8px;
}

/* ── Search grid ── */
.ms-search-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
    margin-bottom: 14px;
}
.ms-field { display: flex; flex-direction: column; gap: 5px; }
.ms-label {
    font-size: 12.5px; font-weight: 700; color: var(--text-secondary);
    display: flex; align-items: center; gap: 5px;
}
.ms-input, .ms-select {
    padding: 9px 12px;
    border: 1.5px solid var(--border); border-radius: 9px;
    font-size: 13.5px; font-family: var(--font-family);
    background: #f8fafc; color: var(--text-primary);
    transition: border-color 0.15s, box-shadow 0.15s; outline: none;
}
.ms-input:focus, .ms-select:focus {
    border-color: var(--primary); background: #fff;
    box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}
.ms-hint { font-size: 11.5px; color: var(--text-muted); line-height: 1.4; }

/* ── Search actions row ── */
.ms-search-actions {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
#searchResultInfo {
    font-size: 12.5px; color: var(--text-muted); font-weight: 500;
}

/* ── Bulk actions bar ── */
.bulk-actions {
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
    padding: 14px 18px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px; margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
}
.bulk-actions-info {
    font-size: 12.5px; font-weight: 700; color: var(--text-secondary);
    margin-right: 4px; white-space: nowrap;
}

/* ── Shared items list ── */
#sharedList {
    display: flex; flex-direction: column; gap: 12px;
}

/* ── Loader ── */
.loading {
    text-align: center; padding: 48px 24px;
    color: var(--text-muted); font-size: 13.5px;
    display: flex; flex-direction: column; align-items: center; gap: 14px;
    background: #fff; border: 1px solid var(--border); border-radius: 12px;
}
.loading::before {
    content: '';
    width: 28px; height: 28px;
    border: 3px solid #e2e8f0; border-top-color: var(--primary);
    border-radius: 50%; animation: spin 0.7s linear infinite;
    display: block;
}

/* ═══════════════════════════════════════════════════════
   JS-RENDERED SHARE ITEM  (classes from manage-share.js)
   ═══════════════════════════════════════════════════════ */

.shared-item {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    transition: box-shadow 0.2s, border-color 0.2s;
}
.shared-item:hover {
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    border-color: #c7d2fe;
}
.shared-item.expired {
    opacity: 0.72;
    border-color: #fca5a5;
}

/* Header row */
.shared-item-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid #f1f5f9;
    gap: 12px; flex-wrap: wrap;
}
.shared-item-header-left {
    display: flex; align-items: center; gap: 12px; min-width: 0;
}
.shared-item-checkbox {
    width: 16px; height: 16px; flex-shrink: 0;
    accent-color: var(--primary); cursor: pointer;
}
.shared-item-email {
    font-size: 14px; font-weight: 700; color: var(--text-primary);
    word-break: break-all;
}

/* Status badge */
.shared-item-status {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 4px 12px; border-radius: 20px;
    font-size: 11.5px; font-weight: 700; white-space: nowrap;
    letter-spacing: 0.02em;
}
.status-active  { background: #dcfce7; color: #15803d; }
.status-expired { background: #fee2e2; color: #b91c1c; }
.status-used    { background: #f1f5f9; color: #64748b; }

/* Info grid */
.shared-item-info {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0;
    padding: 0 18px;
    border-bottom: 1px solid #f8fafc;
}
.info-item {
    padding: 12px 0;
    border-right: 1px solid #f8fafc;
}
.info-item:last-child { border-right: none; }
.info-label {
    font-size: 11px; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 4px;
}
.info-value {
    font-size: 13px; font-weight: 600; color: var(--text-primary);
    display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}

/* Share URL strip */
.shared-item-url {
    padding: 10px 18px;
    font-size: 12px; font-family: 'Courier New', monospace;
    color: var(--text-muted);
    background: #f8fafc;
    border-bottom: 1px solid #f1f5f9;
    word-break: break-all;
    user-select: all;
}

/* Actions row */
.shared-item-actions {
    display: flex; flex-wrap: wrap; gap: 8px;
    padding: 12px 18px;
}

/* ─────────────────────────────
   Buttons (page + JS-rendered)
   ───────────────────────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 8px 14px;
    border: none; border-radius: 8px;
    font-size: 12.5px; font-weight: 600; cursor: pointer;
    font-family: var(--font-family);
    transition: background 0.15s, transform 0.15s;
    white-space: nowrap; line-height: 1;
}
.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover  { background: var(--primary-dark, #4f46e5); transform: translateY(-1px); }
.btn-primary:disabled {
    background: #e2e8f0; color: #94a3b8;
    cursor: not-allowed; transform: none;
}
.btn-danger   { background: #ef4444; color: #fff; }
.btn-danger:hover   { background: #dc2626; transform: translateY(-1px); }
.btn-danger:disabled {
    background: #e2e8f0; color: #94a3b8;
    cursor: not-allowed; transform: none;
}
.btn-secondary {
    background: #f8fafc; color: var(--text-secondary);
    border: 1.5px solid var(--border);
}
.btn-secondary:hover { background: #f1f5f9; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ─────────────────────────────
   Modal
   ───────────────────────────── */
.modal {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.45);
    backdrop-filter: blur(6px);
    z-index: 10002;
    align-items: center; justify-content: center;
    padding: 16px;
    /* override main.css .modal card styles */
    max-width: none !important;
    width: 100% !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    max-height: none !important;
    overflow-y: visible !important;
    animation: none !important;
}
.modal.active { display: flex; }

.modal-content {
    background: #fff; border-radius: 16px;
    padding: 0; max-width: 580px; width: 100%;
    max-height: 92vh; overflow-y: auto;
    box-shadow: 0 24px 64px rgba(0,0,0,0.20);
    border: 1px solid var(--border);
}

/* Modal header bar */
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px 24px 18px;
    border-bottom: 1px solid #f1f5f9;
    position: sticky; top: 0; background: #fff; z-index: 1;
    border-radius: 16px 16px 0 0;
}
.modal-header-title {
    display: flex; align-items: center; gap: 10px;
    font-size: 17px; font-weight: 800; color: var(--text-primary);
}
.modal-header-title svg { color: var(--primary); flex-shrink: 0; }
.modal-close-btn {
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    background: #f1f5f9; border: none; border-radius: 8px;
    color: var(--text-secondary); cursor: pointer;
    font-size: 18px; line-height: 1;
    transition: background 0.15s, color 0.15s;
    font-family: var(--font-family);
}
.modal-close-btn:hover { background: #fee2e2; color: #b91c1c; }

/* Modal body */
.modal-body { padding: 20px 24px 24px; }

/* Section label row (label + right action link) */
.modal-section-label {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 10px;
}
.modal-section-label span {
    font-size: 13px; font-weight: 700; color: var(--text-primary);
}
.modal-section-label .label-sub {
    font-weight: 500; color: var(--text-muted); margin-left: 4px;
}
.modal-section-action {
    font-size: 12.5px; font-weight: 700; color: var(--primary);
    cursor: pointer; text-decoration: none;
    background: none; border: none; padding: 0;
    font-family: var(--font-family);
}
.modal-section-action:hover { text-decoration: underline; color: var(--primary-dark, #4f46e5); }

/* Email search with icon */
.ms-email-search-wrap {
    position: relative; margin-bottom: 0;
}
.ms-email-search-wrap svg {
    position: absolute; left: 12px; top: 50%;
    transform: translateY(-50%); color: var(--text-muted); pointer-events: none;
}
.ms-email-search-wrap input {
    width: 100%; padding: 9px 12px 9px 36px;
    border: 1.5px solid var(--border); border-radius: 9px;
    font-size: 13px; font-family: var(--font-family);
    background: #f8fafc; color: var(--text-primary);
    transition: border-color 0.15s, box-shadow 0.15s; outline: none;
    box-sizing: border-box;
}
.ms-email-search-wrap input:focus {
    border-color: var(--primary); background: #fff;
    box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}

/* Email checkbox list */
#emailCheckboxList {
    max-height: 240px; overflow-y: auto;
    border: 1.5px solid var(--border); border-radius: 9px;
    background: #fff; margin-top: 8px;
}

/* ── Override JS inline styles on platform-group ─── */
#emailCheckboxList .platform-group {
    margin-bottom: 0 !important;
    border: none !important; border-radius: 0 !important;
    border-bottom: 1px solid #f1f5f9 !important;
    overflow: hidden;
}
#emailCheckboxList .platform-group:last-child { border-bottom: none !important; }

#emailCheckboxList .platform-header {
    background: #f8fafc !important;
    padding: 8px 12px !important;
    cursor: pointer;
    display: flex !important; align-items: center !important;
    justify-content: space-between !important;
    border-bottom: 1px solid #f1f5f9 !important;
}
#emailCheckboxList .platform-header span { color: var(--text-secondary) !important; font-size: 12px !important; font-weight: 700 !important; }
#emailCheckboxList .platform-header .platform-arrow { color: var(--text-muted) !important; font-size: 11px !important; }

#emailCheckboxList .platform-emails {
    padding: 0 !important; max-height: none !important; overflow: visible !important;
}

/* Email item inside list */
.email-checkbox-item {
    display: flex !important; align-items: center !important;
    gap: 10px !important; padding: 9px 12px !important;
    margin: 0 !important;
    border-bottom: 1px solid #f8fafc;
    background: #fff !important; border-radius: 0 !important;
    cursor: pointer;
    transition: background 0.1s;
}
.email-checkbox-item:last-child { border-bottom: none; }
.email-checkbox-item:hover { background: #f8fafc !important; }
.email-checkbox-item input[type="checkbox"] {
    width: 16px !important; height: 16px !important;
    flex-shrink: 0; accent-color: var(--primary); cursor: pointer;
    margin: 0 !important;
    appearance: none; -webkit-appearance: none;
    border: 1.5px solid #cbd5e1; border-radius: 50% !important;
    display: inline-flex; align-items: center; justify-content: center;
    transition: background 0.15s, border-color 0.15s;
    background: #fff;
}
.email-checkbox-item input[type="checkbox"]:checked {
    background: var(--primary) !important; border-color: var(--primary) !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2 6l3 3 5-5' stroke='white' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") !important;
    background-size: 10px !important; background-repeat: no-repeat !important; background-position: center !important;
}
.email-checkbox-item label {
    flex: 1 !important; font-size: 13px !important; font-family: 'Courier New', monospace !important;
    color: var(--text-primary) !important; cursor: pointer !important;
    font-weight: 500 !important; margin: 0 !important;
    word-break: break-all; min-width: 0;
}

/* Selected count */
.ms-selected-count {
    font-size: 12px; color: var(--text-muted); font-weight: 500;
    margin-top: 6px;
}
.ms-selected-count strong { color: var(--primary); }

/* Form groups inside modal */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block; font-size: 13px; font-weight: 700;
    color: var(--text-primary); margin-bottom: 6px;
    display: flex; align-items: center; gap: 5px;
}
.form-group input[type="text"],
.form-group input[type="number"],
.form-group select {
    width: 100%; padding: 10px 12px;
    border: 1.5px solid var(--border); border-radius: 9px;
    font-size: 13.5px; font-family: var(--font-family);
    background: #f8fafc; color: var(--text-primary);
    transition: border-color 0.15s, box-shadow 0.15s; outline: none;
    box-sizing: border-box; appearance: none;
}
.form-group input[type="text"]:focus,
.form-group input[type="number"]:focus,
.form-group select:focus {
    border-color: var(--primary); background: #fff;
    box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}
.form-group .select-wrap {
    position: relative;
}
.form-group .select-wrap select {
    width: 100%; padding-right: 36px; cursor: pointer;
}
.form-group .select-wrap::after {
    content: '';
    position: absolute; right: 12px; top: 50%;
    transform: translateY(-50%);
    width: 0; height: 0;
    border-left: 5px solid transparent; border-right: 5px solid transparent;
    border-top: 6px solid var(--text-muted); pointer-events: none;
}
.form-group small {
    display: block; font-size: 11.5px; color: var(--text-muted); margin-top: 5px;
}

/* Two-column form row */
.form-row-2 {
    display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
    margin-bottom: 16px;
}

/* Inline input + button row */
.input-btn-row {
    display: flex; gap: 8px; align-items: center;
}
.input-btn-row input { flex: 1; margin: 0; }

/* Modal footer actions */
.modal-footer {
    display: flex; gap: 10px; margin-top: 20px; padding-top: 16px;
    border-top: 1px solid #f1f5f9;
}
.modal-footer .btn { flex: 1; justify-content: center; }

/* ─────────────────────────────
   Extend presets
   ───────────────────────────── */
.extend-presets {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
}
.extend-preset-btn {
    padding: 10px 6px;
    border: 1.5px solid var(--border); border-radius: 9px;
    background: #f8fafc; color: var(--text-primary);
    font-size: 13px; font-weight: 700; cursor: pointer;
    font-family: var(--font-family);
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    text-align: center;
}
.extend-preset-btn:hover {
    border-color: var(--primary); background: rgba(99,102,241,0.06);
    color: var(--primary);
}
.extend-preset-btn.active {
    background: var(--primary); color: #fff; border-color: var(--primary);
}

/* ─────────────────────────────
   Empty / error states
   ───────────────────────────── */
.empty-state {
    text-align: center; padding: 48px 24px;
    background: #fff; border: 1px solid var(--border); border-radius: 12px;
    color: var(--text-muted);
}
.empty-state svg { margin-bottom: 16px; opacity: 0.35; }
.empty-state p   { font-size: 14px; margin: 0; }

/* ─────────────────────────────
   Footer
   ───────────────────────────── */
.ms-footer {
    border-top: 1px solid #e2e8f0;
    padding-top: 24px; margin-top: 32px; text-align: center;
}
.ms-footer-links {
    display: flex; justify-content: center;
    gap: 24px; flex-wrap: wrap; margin-bottom: 12px;
}
.ms-footer-links a {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 12.5px; color: var(--text-muted); text-decoration: none;
    transition: color 0.15s;
}
.ms-footer-links a:hover { color: var(--primary); }
.ms-footer-copy { font-size: 12px; color: var(--text-muted); margin: 0; }

/* ─────────────────────────────
   Responsive
   ───────────────────────────── */
@media (max-width: 768px) {
    .shared-item-info {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 640px) {
    .ms-page { padding: 20px 16px 40px; }
    .ms-card { padding: 16px; }
    .ms-search-grid { grid-template-columns: 1fr; }
    .bulk-actions { gap: 6px; }
    .shared-item-info { grid-template-columns: 1fr 1fr; }
    .shared-item-header { flex-direction: column; align-items: flex-start; }
    .modal-content { padding: 20px 16px; }
}
