/* ─── Ads Manager ─── */

.am-container {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
}

/* Tabs: Campaigns / Ad Sets / Ads */
.am-tabs {
    display: flex;
    align-items: center;
    gap: 0;
    border-bottom: 1px solid var(--border-color);
    background: rgba(255,255,255,0.02);
    padding: 0 16px;
}

.am-tab {
    padding: 12px 20px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.am-tab:hover {
    color: var(--text-primary);
}

.am-tab.active {
    color: #8b5cf6;
    border-bottom-color: #8b5cf6;
}

.am-tab .am-tab-count {
    background: rgba(139,92,246,0.15);
    color: #8b5cf6;
    font-size: 11px;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 10px;
}

.am-tab.active .am-tab-count {
    background: rgba(139,92,246,0.25);
}

/* Toolbar */
.am-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    gap: 12px;
    flex-wrap: wrap;
}

.am-toolbar-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.am-toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.am-search {
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 7px 12px;
    color: var(--text-primary);
    font-size: 13px;
    width: 220px;
    outline: none;
    transition: border-color 0.15s;
}

.am-search:focus {
    border-color: rgba(139,92,246,0.4);
}

.am-search::placeholder {
    color: var(--text-secondary);
}

.am-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid var(--border-color);
    background: rgba(255,255,255,0.04);
    color: var(--text-primary);
    transition: all 0.15s;
    white-space: nowrap;
}

.am-btn:hover {
    background: rgba(255,255,255,0.08);
}

.am-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.am-btn-primary {
    background: #8b5cf6;
    border-color: #8b5cf6;
    color: #fff;
}

.am-btn-primary:hover {
    background: #7c3aed;
}

.am-btn-danger {
    color: #ef4444;
    border-color: rgba(239,68,68,0.3);
}

.am-btn-danger:hover {
    background: rgba(239,68,68,0.1);
}

.am-btn-sm {
    padding: 4px 10px;
    font-size: 12px;
}

/* Bulk actions bar */
.am-bulk-bar {
    display: none;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: rgba(139,92,246,0.06);
    border-bottom: 1px solid rgba(139,92,246,0.15);
    font-size: 13px;
    color: var(--text-secondary);
}

.am-bulk-bar.visible {
    display: flex;
}

.am-bulk-bar strong {
    color: var(--text-primary);
}

/* Table */
.am-table-wrap {
    overflow-x: auto;
}

.am-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.am-table th {
    text-align: left;
    padding: 10px 14px;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
    position: sticky;
    top: 0;
    background: var(--card-bg);
    z-index: 1;
    cursor: pointer;
    user-select: none;
}

.am-table th:hover {
    color: var(--text-primary);
}

.am-table th .sort-icon {
    margin-left: 4px;
    font-size: 10px;
    opacity: 0.4;
}

.am-table th.sorted .sort-icon {
    opacity: 1;
    color: #8b5cf6;
}

.am-table td {
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    color: var(--text-primary);
    white-space: nowrap;
}

.am-table tr:hover td {
    background: rgba(255,255,255,0.02);
}

.am-table tr.am-row-adset td {
    padding-left: 40px;
    background: rgba(255,255,255,0.01);
}

.am-table tr.am-row-ad td {
    padding-left: 64px;
    background: rgba(255,255,255,0.015);
}

.am-table tr.am-row-adset td:first-child,
.am-table tr.am-row-ad td:first-child {
    position: relative;
}

.am-table tr.am-row-adset td:first-child::before {
    content: '';
    position: absolute;
    left: 22px;
    top: 0;
    bottom: 0;
    width: 1px;
    background: rgba(139,92,246,0.2);
}

.am-table tr.am-row-ad td:first-child::before {
    content: '';
    position: absolute;
    left: 46px;
    top: 0;
    bottom: 0;
    width: 1px;
    background: rgba(139,92,246,0.12);
}

/* Checkbox */
.am-check {
    width: 16px;
    height: 16px;
    accent-color: #8b5cf6;
    cursor: pointer;
    margin: 0;
}

/* Name cell */
.am-name-cell {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 200px;
}

.am-expand-btn {
    width: 22px;
    height: 22px;
    border: none;
    background: rgba(255,255,255,0.06);
    color: var(--text-secondary);
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    transition: all 0.15s;
    flex-shrink: 0;
}

.am-expand-btn:hover {
    background: rgba(139,92,246,0.15);
    color: #8b5cf6;
}

.am-expand-btn.expanded {
    transform: rotate(90deg);
}

.am-level-icon {
    font-size: 12px;
    color: var(--text-secondary);
    flex-shrink: 0;
    width: 16px;
    text-align: center;
}

.am-level-icon.campaign { color: #8b5cf6; }
.am-level-icon.adset { color: #3b82f6; }
.am-level-icon.ad { color: #10b981; }

.am-item-name {
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 280px;
    font-weight: 500;
}

.am-editable-name {
    cursor: text;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background 0.1s;
}

.am-editable-name:hover {
    background: rgba(255,255,255,0.06);
}

/* Status badge */
.am-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.am-status.active {
    background: rgba(16,185,129,0.12);
    color: #10b981;
}

.am-status.paused {
    background: rgba(251,191,36,0.12);
    color: #fbbf24;
}

.am-status.deleted, .am-status.archived {
    background: rgba(239,68,68,0.1);
    color: #ef4444;
}

/* Toggle button */
.am-toggle {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    transition: all 0.15s;
    background: rgba(255,255,255,0.04);
    color: var(--text-secondary);
}

.am-toggle:hover {
    background: rgba(255,255,255,0.1);
    color: var(--text-primary);
}

/* Actions dropdown */
.am-actions-cell {
    display: flex;
    align-items: center;
    gap: 4px;
}

.am-action-btn {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    background: transparent;
    color: var(--text-secondary);
    transition: all 0.1s;
}

.am-action-btn:hover {
    background: rgba(255,255,255,0.08);
    color: var(--text-primary);
}

.am-action-btn.danger:hover {
    background: rgba(239,68,68,0.1);
    color: #ef4444;
}

/* Budget cell - editable */
.am-budget-cell {
    display: flex;
    align-items: center;
    gap: 4px;
}

.am-budget-input {
    width: 80px;
    background: rgba(255,255,255,0.04);
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 4px 8px;
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
    transition: border-color 0.15s;
}

.am-budget-input:focus {
    border-color: rgba(139,92,246,0.4);
    background: rgba(255,255,255,0.06);
}

.am-budget-input::-webkit-inner-spin-button {
    display: none;
}

/* Empty state */
.am-empty {
    padding: 60px 20px;
    text-align: center;
    color: var(--text-secondary);
}

.am-empty i {
    font-size: 36px;
    margin-bottom: 12px;
    opacity: 0.3;
}

.am-empty p {
    font-size: 14px;
}

/* Loading */
.am-loading {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 13px;
}

.am-loading i {
    margin-right: 8px;
}

/* Breadcrumb for drill-down */
.am-breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 16px 0 0;
    font-size: 13px;
    color: var(--text-secondary);
}

.am-breadcrumb-item {
    cursor: pointer;
    color: #8b5cf6;
    font-weight: 500;
}

.am-breadcrumb-item:hover {
    text-decoration: underline;
}

.am-breadcrumb-sep {
    color: var(--text-secondary);
    font-size: 10px;
}

.am-breadcrumb-current {
    color: var(--text-primary);
    font-weight: 600;
}

/* ─── Edit Modal ─── */
.am-edit-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.am-edit-overlay.active {
    opacity: 1;
}

.am-edit-panel {
    width: 520px;
    max-width: 95vw;
    height: 100%;
    background: var(--card-bg, #1e293b);
    border-left: 1px solid rgba(255,255,255,0.08);
    display: flex;
    flex-direction: column;
    animation: amSlideIn 0.25s ease;
}

@keyframes amSlideIn {
    from { transform: translateX(40px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.am-edit-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
}

.am-edit-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary, #f1f5f9);
    display: flex;
    align-items: center;
}

.am-edit-close {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 8px;
    background: rgba(255,255,255,0.05);
    color: #94a3b8;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.am-edit-close:hover {
    background: rgba(255,255,255,0.1);
    color: #f1f5f9;
}

.am-edit-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.am-edit-section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #8b5cf6;
    padding-top: 8px;
    border-top: 1px solid rgba(255,255,255,0.06);
    margin-top: 4px;
}

.am-edit-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.am-edit-field label {
    font-size: 12px;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.am-edit-input {
    padding: 10px 14px;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    background: rgba(255,255,255,0.04);
    color: var(--text-primary, #f1f5f9);
    font-size: 13px;
    font-family: inherit;
    transition: border-color 0.15s;
    outline: none;
    width: 100%;
    box-sizing: border-box;
}

.am-edit-input:focus {
    border-color: rgba(139,92,246,0.5);
}

.am-edit-input option {
    background: #1e293b;
    color: #f1f5f9;
}

.am-edit-hint {
    font-size: 11px;
    color: #64748b;
    line-height: 1.4;
}

.am-edit-row {
    display: flex;
    gap: 12px;
}

.am-edit-row .am-edit-field {
    flex: 1;
}

.am-edit-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.am-edit-tag {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    background: rgba(139,92,246,0.1);
    border: 1px solid rgba(139,92,246,0.2);
    border-radius: 6px;
    font-size: 12px;
    color: #a78bfa;
}

.am-edit-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
}

.am-edit-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.15s;
}

.am-edit-btn.secondary {
    background: rgba(255,255,255,0.06);
    color: #94a3b8;
}

.am-edit-btn.secondary:hover {
    background: rgba(255,255,255,0.1);
    color: #e2e8f0;
}

.am-edit-btn.primary {
    background: linear-gradient(135deg, #8b5cf6, #6d28d9);
    color: #fff;
}

.am-edit-btn.primary:hover {
    filter: brightness(1.1);
}

.am-edit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Responsive */
@media (max-width: 768px) {
    .am-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .am-search {
        width: 100%;
    }
    .am-tabs {
        overflow-x: auto;
    }
    .am-item-name {
        max-width: 160px;
    }
    .am-edit-panel {
        width: 100%;
    }
    .am-edit-row {
        flex-direction: column;
        gap: 16px;
    }
}
